Python Forum
sqlite3 wildcard use problems
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sqlite3 wildcard use problems
#1
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
Reply
#2
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))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading Excel file and use a wildcard in file name and sheet name randolphoralph 6 7,147 Jan-13-2022, 10:20 PM
Last Post: randolphoralph
  pymongo wildcard query issue MikeAW2010 2 4,270 Jul-06-2021, 09:25 AM
Last Post: swag
  python script to get wildcard mask output in the following format techrichit 0 3,835 Aug-10-2018, 11:01 PM
Last Post: techrichit
  Finding directory based on wildcard? jkimrey 4 3,402 Apr-25-2018, 10:02 AM
Last Post: mlieqo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020