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() connection.commit()
# Registrar valores nas colunas da tabela # Registrar valores nas colunas da tabela
# CUIDADO: sql injection sql = (
cursor.execute(
f'INSERT INTO {TABLE_NAME} ' f'INSERT INTO {TABLE_NAME} '
'(id, name, weight) ' '(name, weight) '
'VALUES ' 'VALUES '
'(NULL, "Helena", 4), (NULL, "Eduardo", 10)' '(?, ?)'
) )
cursor.execute(sql, ['Joana', 4])
connection.commit() connection.commit()
print(sql)
cursor.close() cursor.close()
connection.close() connection.close()