在google colab中加载并使用sqlite文件

问题描述 投票:0回答:1
print ('Files in Drive:')

!ls drive/AI`

'database.sqlite'文件已存在于驱动器中。当我在Google Colab中运行上述代码时,我的驱动程序中显然存在我的sqlite文件。但是每当我对这个文件运行一些查询时,它说

# using the SQLite Table to read data.
con = sqlite3.connect('database.sqlite') 

#filtering only positive and negative reviews i.e. 
# not taking into consideration those reviews with Score=3
filtered_data = pd.read_sql_query("SELECT * FROM Reviews WHERE Score !=3",con)

DatabaseError:sql上的执行失败'SELECT * FROM评论WHERE得分!= 3':没有这样的表:评论

sqlite google-colaboratory
1个回答
0
投票

上传文件后,单击左侧的导航窗格。在“文件”选项卡下,右键单击上载的文件,然后选择“复制路径”。在连接中使用此复制的路径:

con = sqlite3.connect('content/database.sqlite') 
© www.soinside.com 2019 - 2024. All rights reserved.