Bart Friederichs
Bart Friederichs

Reputation: 33511

No access to database

I am trying to open an FDB file, but it doesn't seem to work. Whatever I try, I get this error:

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)

I am running this code as user apache, and the same user just copied the FDB file into that location, so I am pretty sure the user has read/write access.

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()

Even when running the script as root, I get the same error.

Upvotes: 1

Views: 150

Answers (1)

Bart Friederichs
Bart Friederichs

Reputation: 33511

The problem was in the fact that the FDB file has to be read/writable by the firebird user.

Setting that correctly made it work.

Upvotes: 1

Related Questions