I am trying to create a database in sqlite3 in python, but it shows this error message after running the function:
cursor.execute(sql) sqlite3.OperationalError: near "(": syntax error
The problem apparently is in the Method for the cursor named Execute as the debugging sections indicates that there is an operational error in that line, but is unclear the reason as it was coded as expected. However, the table is created but as this error shows it blocks my program. The issue is not in the syntax of the query as I tried changing the position of the column names and the variable type.
Please help me find the problem.
import sqlite3
def table_personal_data():
conn = sqlite3.connect('mailroom.db')
cursor = conn.cursor()
sql='''CREATE TABLE IF NOT EXISTS DONORS(
ID PRIMARY KEY (NAME,NAME),
NAME VARCHAR(40) NOT NULL,
LASTNAME VARCHAR(40) NOT NULL,
EMAIL VARCHAR(50) NOT NULL,
DRIVER_LICENSE VARCHAR(50) NOT NULL)'''
cursor.execute(sql)
conn.commit()
cursor.close()
conn.close()
table_personal_data()
I tried to change the sqlite3 code in the query section, but it is not the issue.
It is your query syntax error, check this
It is correct syntax