Usando placeholders
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user