How Do I Get Around Not Being Able To Parse A Table Name Into A Python Sqlite Query?
I have a python3 program that I'm making which uses a sqlite database with several tables, I want to create a selector module to allow me to chose which table to pull data from. I
Solution 1:
Right. You can not use parameter substitution to specify the table. So instead you must do string manipulation:
c.execute("SELECT * FROM {t} ".format(t=tablename))
Solution 2:
I don't know if this is a python3 thing but it seems easiest to just do this:
c.execute("SELECT * FROM %s "% tablename)
Post a Comment for "How Do I Get Around Not Being Able To Parse A Table Name Into A Python Sqlite Query?"