Skip to content
Advertisement

Connect to Firebird database as read-only

I want to connect to a Firebird database read-only (because the location where the .fdb is read-only for my application.

I connect like this:

conn = fdb.connect(dsn="/path/to.fdb", user='****', password='****', charset='iso8859_1')

The error I am getting is:

Error while connecting to database:n- SQLCODE: -551n- no permission for read-write access to database /path/to.fdb’, -551, 335544352

I am using FDB v2.0. I couldn’t find anything in the online documentation about a read-only connection.

Advertisement

Answer

Unfortunately, what you want is not possible. Firebird doesn’t have a concept of read-only connections. Every connection needs to be able to write information in the database for administration of transactions (this even applies for read-only transactions).

The only exception is for databases that have been marked as a read-only database using gfix. In that case, transactions piggyback on the last committed transaction id. However, marking a database read-only will make it read-only for all connections.

If your application needs read-only access, while other applications need write access to the same database, the only solution is to use Firebird server*, and use users (and roles) to assign sufficient rights to be able to read but not write to the database.


*: Firebird Embedded might be sufficient, but as the user then needs read/write access to the database, it would be simpler to circumvent this form of access control for malicious actors.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement