lundi 21 décembre 2015

Create Table using a variable in python

I would like to use a python output to create table in sqlite3. I've tried some possibilities but the script create tables with the given name. Is it possible to create a table with a variable?

for name in test.all():
    return name

or just

name = 'dbName'
#
conn = sqlite3.connect("my_db")
db = conn.cursor()
db.execute('''CREATE TABLE (here var)(id, column1, column2, column2)''')
conn.commit()
db.close()

Aucun commentaire:

Enregistrer un commentaire