I'd like to run multiple statements with one command. Is it possible:
This is the SQL command:
UPDATE toggle SET state='0' WHERE feature_name=‘feature_1;
UPDATE toggle SET state=‘1’ WHERE feature_name=‘feature_2’;
UPDATE toggle SET state=‘1’ WHERE feature_name=‘feature_3’;
For one command I run something like that:
import MySQLdb
myDB = MySQLdb.connect(host=host, port=db_port, user=user, passwd=db_password, db=db)
cHandler = myDB.cursor()
cHandler.execute(query)
But this obviously works only for a single statement
Thanks!
asked Sep 30, 2018 at 7:33
Pavel Zagalsky
1,6567 gold badges25 silver badges57 bronze badges
1 Answer 1
Use parameterized query and executemany.
answered Sep 30, 2018 at 7:37
Lie Ryan
65.3k14 gold badges103 silver badges151 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py