sqlite - Can't retrieve str from mySqlite3 -


im trying retrieve latest versions of audit questions stored in table t3 of hs_audit.sqlite. have tried multiple versions of cur.exectute line keep getting result = none. i'm new sqlite can me correct syntax. if execute cur.execute line follows

cur.execute("select hvq1 t3 audit_ver = 1") 

and remove

con.text_factory = str 

it works think problem must use of variables in sqlite command.

max_audit_ver = 1 audit_questions = ["hvq1", "hvq2", "hvq3", "hvq4", "hvq5"]          count = 0         quest in audit_questions:             con = sqlite3.connect("hs_audit.sqlite")             con.text_factory = str             cur = con.cursor()             cur.execute("select '%s' t3 audit_ver = '%s'" %  (quest, max_audit_version))             result = cur.fetchone()             con.close()             print "question =%s" % (quest)             print "audit version =%s" % (max_audit_version)             print "the count =%s" % (count)             print "the return db =%s" % (result)             count += 1 

mind synthax... max_audit_version , max_audit_ver

on other hand, should read this page, find important note such :

# never -- insecure! symbol = 'rhat' c.execute("select * stocks symbol = '%s'" % symbol)  # instead t = ('rhat',) c.execute('select * stocks symbol=?', t) print c.fetchone()  # larger example inserts many records @ time purchases = [('2006-03-28', 'buy', 'ibm', 1000, 45.00),              ('2006-04-05', 'buy', 'msft', 1000, 72.00),              ('2006-04-06', 'sell', 'ibm', 500, 53.00),             ] c.executemany('insert stocks values (?,?,?,?,?)', purchases) 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -