sqlite3 - Writing a python file to an online SQL database -


i'm trying take output python code , write chart on online sql database. attempted use sqlite3 here:

def write_sql(index, data):       conn = sqlite3.connect('tt.db')      c = conn.cursor()     #c.execute('''create table iplist(ip text, availibility real)''')      key in data:             print key         c.execute("insert iplist values (%s,%d)" , (key, data[key]))      conn.commit() 

however, operational error , i'm unsure of how connect online database opposed local test document.

assuming you're using standard sqlite3 library, you're specifying parameters query incorrectly. documentation:

the sqlite3 module supports 2 kinds of placeholders: question marks (qmark style) , named placeholders (named style).

you're attempting use ansi c printf format codes, not supported. try either of following:

c.execute("insert iplist values (?,?)" , (key, data[key]))  c.execute("insert iplist values (:key,:data)" , {"key":key, "data":data[key]}) 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -