无法访问数据库

时间:2019-04-02 07:55:49

标签: python firebird

我正在尝试打开FDB文件,但是它似乎不起作用。无论我尝试什么,都会收到此错误:

Opening ./20190401_database.fdb
Traceback (most recent call last):
  File "test.py", line 16, in <module>
    conn = fdb.connect(dsn=local_copy, user='****', password='****', charset='iso8859_1')
  File "/usr/local/lib/python3.6/site-packages/fdb/fbcore.py", line 848, in connect
    "Error while connecting to database:")
fdb.fbcore.DatabaseError: ('Error while connecting to database:\n- SQLCODE: -551\n- no permission for read-write access to database /var/www/wsgi/data/20190401_database.fdb', -551, 335544352)

我正在以用户apache的身份运行此代码,并且同一用户刚刚将FDB文件复制到了该位置,所以我很确定该用户具有读/写访问权限。

import fdb
from datetime import date, timedelta

DB_PATH="."

yesterday = date.today() - timedelta(days = 1)
yesterday = yesterday.strftime("%Y%m%d")
filename = f'{yesterday}_database.fdb'
local_fullpath = f'{DB_PATH}/{filename}'

local_copy = local_fullpath

print("Opening "+local_copy)
conn = fdb.connect(dsn=local_copy, user='****', password='****', charset='iso8859_1')

conn.close()

即使以root身份运行脚本,我也会遇到相同的错误。

1 个答案:

答案 0 :(得分:1)

问题在于,firebird用户必须可以读取/写入FDB文件。

进行正确设置以使其正常工作。