yhat / pandasql

sqldf for pandas
MIT License
1.34k stars 185 forks source link

Cannot handle quotes around table name #74

Open isthisthat opened 5 years ago

isthisthat commented 5 years ago

Even though the following is valid sql, pandasql gives an error:

import pandasql as pdsql
df1 = pd.DataFrame({
    'name': ['Joe', 'Bill', 'Bob'],
    'weight': [70, 85, 75]
})

q = 'select * from "df1"'
print(pdsql.sqldf(q, locals()))
PandaSQLException: (sqlite3.OperationalError) no such table: df1 [SQL: 'select * from "df1"']

Removing the quotes around the table name fixes this. This makes me slightly nervous about pandasql's handling of quotes and backticks :|

eliax1996 commented 4 years ago

try: q = 'select * from df1'