Reputation: 25
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 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...
Upvotes: 2
Views: 2900
Reputation: 169304
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,
...
Upvotes: 7
Reputation: 14175
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.
Upvotes: 1