sqlite3 "OperationalError: near "(": syntax error" python -


simply put trying make sql database table , input data it. have working in simpler way, when put script results in error. i'm hoping simple missed. help/advice appreciated.

conn = sqlite3.connect('data1.db')  c = conn.cursor()  # create table c.execute('''create table data_output6          (date text, output6mv real)''')   averages_norm = []  i, x in enumerate(averages):     averages_norm.append(x*output_factor)     c.execute("insert data_output6 values (%r,%r)" %(xdates[i],averages_norm[-1])) conn.commit() 

results in error:

57     i, x in enumerate(averages): 58         averages_norm.append(x*output_factor) ---> 59         c.execute("insert data_output6 values (%r,%r)"%(xdates[i],averages_norm[-1])) 60     conn.commit() 61  

operationalerror: near "(": syntax error

simply put, let db api formatting:

c.execute("insert data_output6 values (?, ?)", (xdates[i], averages_norm[-1])) 

and refer documentation https://docs.python.org/2/library/sqlite3.html mentioned:

instead, use db-api’s parameter substitution.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -