I am trying to select a particular column of a table in a sqlite database. I am using the following:
cursor = connection.execute('select Case from SUMMARY')
Even though the column name is correct, whenever I run the code, i receive the following error.
The same happens when I try to fetch the column index.
Whenever i try any other column, I can fetch all the column’s data.
OperationalError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_15288/2883478922.py in <module>
1 import sqlite3
2 connection = sqlite3.connect("../DB_Cases.sqlite")
----> 3 cursor = connection.execute('select Case from SUMMARY')
OperationalError: near "from": syntax error
>Solution :
case is reserved keyword in SQLite.
Using double quotes in the query as mentioned in the SQLite documentation should get your query working.