Reputation: 1
Can't insert more than two data's in the mysql database i'm running the code in python using raspberry pi. the code i used is
query="INSERT INTO import(customer,package) VALUES('%s','%s')"
cursor.execute(query,(name,data))
it gives an error to check the syntax.
Upvotes: 0
Views: 1082
Reputation: 180917
When using parameters, you should not quote your parameters. That is, your query should be;
query="INSERT INTO import(customer,package) VALUES(%s, %s)"
Upvotes: 1
Reputation: 3120
You also need to add connection.commit()
after your insert/update queries.
Example
connection = MySQLdb.connect(*data)
cursor = connection.cursor()
cursor.execute(<query>)
connection.commit()
Upvotes: 5