MySQL Forums
Forum List  »  Connector/Python

Using Python variables in MySQL INSERT statement
Posted by: Cheese Cake
Date: June 03, 2008 11:58AM

Hi all,

I'm having trouble getting local Python variables to work in my INSERT statements:

So far, I've opened a connection to my database, which contains a table called data(3 columns):

currtime = "Jun 03 11:11:06 2008"
currtemp = 75
currsat = 60

cur.execute('INSERT INTO data (time,temp,sat) VALUES (currtime,currtemp,currsat)')

However, this gives me an error. How can I get variables to work?

Options: ReplyQuote

Written By
Using Python variables in MySQL INSERT statement
June 03, 2008 11:58AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.