【发布时间】:2019-05-14 17:07:53
【问题描述】:
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 Reviews WHERE Score != 3' 执行失败:没有这样的表:Reviews
【问题讨论】:
-
如果您提供虚假文件名,
connect是否会引发错误? (一种可能性是您需要将工作目录更改为/content/drive/My\ Drive/。)另外,您如何确认数据库中存在Reviews表? (另一种可能是报错信息正确,没有这个表。) -
@BobSmith 谢谢!将目录更改为 /content/drive/My\ Drive/ 有效。我使用 %cd / 而不是 %cd ./ 来更改目录。
标签: sqlite google-colaboratory