print msg
returns ['2013-07-08 10','temperature','kitchen','22.5']
When I run this code :
data="bdd.sq3"
conn=sqlite3.connect(data)
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS temperature (date TEXT, type TEXT, zone TEXT, value REAL)")
cur.execute("INSERT INTO temperature (date TEXT, type TEXT, zone TEXT, value REAL) VALUES(?,?,?,?)",(msg))
I have this error :
cur.execute("INSERT INTO temperature (date TEXT, type TEXT, zone TEXT, value REAL) VALUES(?,?,?,?)",(msg))
sqlite3.OperationnalError: near "TEXT": syntax error
But I can't see what's wrong. I use similar code in other program and it works perfectly.
You don't need those TEXT
tags when inserting in your database. You only use that when creating the database table. Just make sure that the values you're inserting in the database are the same type as you've given when creating the table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.