I am learning python 2.7.4/MySQL 5.6. I have a db by name TESTDB. It has a Table called EMPLOYEE. I've been trying to insert data using executemany(). I am getting
Type Error: not enough arguments for format string
I tried to learn from the various answers for similar problem posted in stack overflow and make changes in my code without success. My code is:
import MySQLdb
# Open database connection
import MySQLdb
db = MySQLdb.connect("localhost","testuser","test123","TESTDB" )
# prepare a cursor object using cursor() method
cursor = db.cursor()
# Prepare SQL query to INSERT a record into the database.
cursor.executemany("""INSERT INTO EMPLOYEE(ID,FIRST_NAME,LAST_NAME,AGE,SEX,INCOME)
VALUES(%s,%s,%s,%s,%s,%s)""" %
{5,'Geetha','Ramam',22,'F',5600},
{6,'Radha','Krishna',34,'F',7500},
{7,'Ramesh','Tiwari',28,'M',6500},
{8,'Govind','Nihalani',45,'M',8900},
{9,'Yousuf','Patel',21,'M',4500})
db.commit()
cursor.close()
# disconnect from server
db.close()
Shall be grateful for a suggestion.