Sep-24-2017, 12:32 PM
I wish to make a function that creates tables from a tablename list i provide
I get this error
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import sqlite3 def creat_tables(): conn = sqlite3.connect( 'listatest.db' ) c = conn.cursor() tablelist = ( 'unu' , 'doi' , 'trei' ) for tablename in tablelist: create = 'CREATE TABLE IF NOT EXISTS ' + tablename + ' (numar_par INTEGER PRIMARY KEY, echipa1 TEXT UNIQUE, scor1 TEXT, scor2 TEXT, echipa2 TEXT, ' 'cota FLOAT, miza INT, stare INT)' c.execute(create) |
Error:"C:\Program Files\Python36\python.exe" "D:/pariuri/python/teste sqlite/TutorialSqlite.py"
Traceback (most recent call last):
File "D:/pariuri/python/teste sqlite/TutorialSqlite.py", line 6, in <module>
creat_tables()
File "D:\pariuri\python\teste sqlite\create_tables.py", line 17, in creat_tables
c.execute(create)
sqlite3.OperationalError: near " ": syntax error
Process finished with exit code 1