[Tutor] How to create a sqlite table schema dynamically

Toni Fuente tonifuente at yahoo.co.uk
Wed Mar 19 13:19:53 CET 2014


Hello everyone,

I am stack with a problem that I can't find a solution:

I need to create a sqlite schema dynamically, I've got a dictionary with
text keys: "RedHat", "CentOS", "SLES9",..., "etc", "etc"

My intention was at the time of creating the table schema run a loop
through the dictionary keys and incorporate them to the schema:

for os in osDict.items():
   cur.execute('''CREATE TABLE mytable(week INTEGER NOT NULL, os TEXT NOT NULL, number INTEGER NOT NULL)''')

But I don't know how to pass the os key to the sqlite command.

Thank you in advance for any help,
Kind regards,


-- 
Toni

Tímido Busca..., Bueno No..., Es Igual... Nada.


More information about the Tutor mailing list