Python Forum

Full Version: sqlite3 wildcard use problems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

i am trying to have my python script insert values into one of several tables within the same database.
i tried with something like the following and played around a bit but decided to ask for help
    
def insrt(table):
c.execute('INSERT INTO {x} (c1, c2, c3) VALUES( ?,?,?) ', (v1, v2, v3)).format(x=table)
thanks for any help
You can generate a separate SQL statement. Obviously this code is not tested.
sql_stmt='INSERT INTO {0} (c1, c2, c3) VALUES( ?,?,?) '.format(table)
## print to see if it is what you want
print(sql_stmt)
c.execute(sql_stmt, (v1, v2, v3))