I am having an error while trying to run a query with the magic function %sql
in jupyter notebook
My query:
%sql SELECT "Elementary, Middle, or High School" FROM chicago_public_schools_data LIMIT 1;
Error:
- sqlite:///socioeconomic.db (sqlite3.OperationalError) near "or": syntax error [SQL: SELECT Elementary, Middle, or High School FROM chicago_public_schools_data LIMIT 1;] (Background on this error at: https://sqlalche.me/e/20/e3q8)
I'm sure that column name is matching, controlled by selecting all columns, or printing with 'df.columns'.
Index(['School_ID', 'Elementary, Middle, or High School','Street_Address'......
Don't know how can I solve this.
I tried to use (")
instead of (')
, or use %%sql
instead of %sql
Here is an example screenshot from my data:
Here is a screenshot from the command line with my query, and example query. I'm getting output with my query in the command line. So my syntax works well on the command line but not on jupyter notebook.