简体   繁体   English

我的 sqlite3 数据库出了什么问题?

[英]What's going wrong with my sqlite3 database?

I try to open a connection to my sqlite database, when this happens:当发生这种情况时,我尝试打开到我的 sqlite 数据库的连接:

Traceback (most recent call last):
  File "/Users/amirjodelmans/Desktop/chemcalc.py", line 3, in <module>
    hassan = sqlite3.connect("Untitled/Applications/molairemassa.db")
sqlite3.OperationalError: unable to open database file

The database can be found in the exact map, as shown in the error message, and this is the only code I've written:可以在准确的 map 中找到数据库,如错误消息所示,这是我编写的唯一代码:

import sqlite3

hassan = sqlite3.connect("Untitled/Users/amirjodelmans/Applications/molairemassa.db")

Does anybody know how to fix this?有人知道如何解决这个问题吗?

It seems that you just put the wrong path in the string.看来您只是在字符串中输入了错误的路径。

Could you try to change your path to an absolute path like this:您能否尝试将路径更改为这样的绝对路径:

import sqlite3

hassan = sqlite3.connect("/Users/amirjodelmans/Applications/molairemassa.db")

Generally, if a path starts with / , it means an absolute path, if path starts with ./ or other alphanumerics, it represents an relative path.通常,如果路径以/开头,则表示绝对路径,如果路径以./或其他字母数字开头,则表示相对路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM