From MySQLdb User’s Guide:
c.executemany(
"""INSERT INTO breakfast (name, spam, eggs, sausage, price)
VALUES (%s, %s, %s, %s, %s)""",
[
("Spam and Sausage Lover's Plate", 5, 1, 8, 7.95 ),
("Not So Much Spam Plate", 3, 2, 0, 3.95 ),
("Don't Wany ANY SPAM! Plate", 0, 4, 3, 5.95 )
] )
so in your case:
c.executemany("insert into T (F1,F2) values (%s, %s)",
[('a','b'),('c','d')])
Related Contents:
- Installing specific package version with pip
- Database does not update automatically with MySQL and Python
- mysql-python install error: Cannot open include file ‘config-win.h’
- How to insert pandas dataframe via mysqldb into database?
- Install mysql-python (Windows)
- When to close cursors using MySQLdb
- Python 3.4.0 with MySQL database
- Python MYSQL update statement
- How can I use executemany to insert into MySQL a list of dictionaries in Python
- ImportError: No module named MySQLdb
- Print the actual query MySQLdb runs?
- Can’t install mysql-python (newer versions) in Windows
- Dynamic SQL Queries with Python and mySQL
- What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?
- Visibility of global variables in imported modules
- Why do integers in database row tuple have an ‘L’ suffix?
- How to install Python MySQLdb module using pip?
- How can I connect to MySQL in Python 3 on Windows?
- “Cannot open include file: ‘config-win.h’: No such file or directory” while installing mysql-python
- How can I change the default Mysql connection timeout when connecting through python?
- How to install MySQLdb (Python data access library to MySQL) on Mac OS X?
- Integrating MySQL with Python in Windows
- Enable Python to Connect to MySQL via SSH Tunnelling
- Inserting a Python datetime.datetime object into MySQL
- How to replace Django’s primary key with a different integer that is unique for that table
- Using Django database layer outside of Django?
- Python: use mysqldb to import a MySQL table as a dictionary?
- Cannot return results from stored procedure using Python cursor
- MySQL — Joins Between Databases On Different Servers Using Python?
- How to enable MySQL client auto re-connect with MySQLdb?
- SQLAlchemy ON DUPLICATE KEY UPDATE
- Python Mysql, “commands out of sync; you can’t run this command now”
- How to build a flask application around an already existing database?
- Python MySQLdb execute table variable [duplicate]
- Python and MySQLdb: substitution of table resulting in syntax error
- ImportError: No module named ‘MySQL’
- Python mySQL Update, Working but not updating table
- Python import MySQLdb error – Mac 10.6
- Python Pandas to_sql, how to create a table with a primary key?
- Speeding (Bulk) Insert into MySQL with Python
- How to run Django’s test database only in memory?
- Python MySQLdb: connection.close() VS. cursor.close()
- Python: MySQLdb and “Library not loaded: libmysqlclient.16.dylib”
- cursor.fetchall() vs list(cursor) in Python
- How to filter (or replace) unicode characters that would take more than 3 bytes in UTF-8?
- Using MySQL in Flask
- How to make an Inner Join in django?
- Single Django model, multiple tables?
- MySQL Improperly Configured Reason: unsafe use of relative path
- How can I insert NULL data into MySQL database with Python?