Usando placeholders

This commit is contained in:
Luiz Otávio
2023-04-01 13:23:11 -03:00
parent f52f4b50c5
commit ee84abc178

View File

@@ -30,14 +30,15 @@ cursor.execute(
connection.commit()
# Registrar valores nas colunas da tabela
# CUIDADO: sql injection
cursor.execute(
sql = (
f'INSERT INTO {TABLE_NAME} '
'(id, name, weight) '
'(name, weight) '
'VALUES '
'(NULL, "Helena", 4), (NULL, "Eduardo", 10)'
'(?, ?)'
)
cursor.execute(sql, ['Joana', 4])
connection.commit()
print(sql)
cursor.close()
connection.close()