-1

错误:

PandaSQLException: (sqlite3.OperationalError) no such table: aadhaar_data [SQL: 'select registrar,enrolment_agency from aadhaar_data limit 50;'] (此错误的背景:http ://sqlalche.me/e/e3q8 )

我的代码:

import pandas as pd
import pandasql as ps
#how to use sql commands

df=pd.read_csv("C:\\Users\\lenovo\\.spyder-py3\\Aadhaar_data.csv")
#we rename the columns
# by replacing spaces with underscores and setting all characters to 
lowercase, so the
# column names more closely resemble columns names one might find in a table
df.rename(columns = lambda x: x.replace(' ', '_').lower(), inplace=True)
print(df)
q="""SELECT registrar,enrolment_agency FROM Aadhaar_data lIMIT 50;"""
#p="""SELECT * from aadhar_data;"""\
aadhaar_solution = ps.sqldf(q.lower(), locals())
print(aadhaar_solution)
aadhaar_solution=ps.execute_sql(q)`
4

1 回答 1

0

这很简单——这意味着该表在数据库中不存在。我可以看到您键入它的方式存在一些不一致之处 - 例如,您的代码有表格,Aadhaar_data而在其他地方您有它,aadhar_data而在另一个地方有aadhaar_data. 您要么在某处拼错了表格,要么根本没有将其插入 - 我在您的代码中没有看到您实际将数据插入到您正在查询的表格中的任何地方。

于 2018-04-13T07:50:44.147 回答