Whenever I try to create a table using python and sqlite3, it gives me the following error:
Traceback (most recent call last)
File "directory.py", line 14, in <module>
'Children' TEXT, 'Other' TEXT, 'Masul' TEXT);''')
sqlite3.OperationalError: near ")": syntax error
The way I'm trying to create the table is:
conn.execute('''create table Jamaat
(id integer primary key,
Email TEXT,
LastName TEXT,
Address1 TEXT,
Apt TEXT,
Address2 TEXT,
City TEXT,
State TEXT,
Zip TEXT,
HomePhone TEXT,
FaxNumber TEXT,
Primary TEXT,
Spouse TEXT,
Children TEXT,
Other TEXT,
Masul TEXT);''')
conn.commit()
I'm using python 2.7 and 开发者_JAVA技巧trying to import a csv spreadsheet into sqlite3
Thanks in advance EDIT: I've tried the code without the trailing comma and it still doesn't work...
Often when you get this kind of error it is because you are using keywords as column (or table) names.
I see that you have a column called primary
.
You will want to put backticks around it or rename it because it is a keyword in SQLite; e.g.:
...
`Primary` TEXT,
...
You have a trailing "," before the closing parenthesis.
There's a missing )
in your sample, and since the error is in your SQL you should probably include the actual execute statement not ...
.
But i'd say your error is a trailing ,
at the end of the list of your columns.
精彩评论