Hello!
There is an application on Flask.

from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config.from_pyfile(filename='settings.py', silent=True) db = SQLAlchemy() db.init_app(app) 

How to properly connect to the database or what settings to make so that the daemon can process and write to the database in parallel, and the Flask application shows a webcam. Now when I try to open the web, I get a 502 error, and in the logs:

 fdb.fbcore.DatabaseError: ('Error while connecting to database:\n- SQLCODE: -902\n- I/O error during "lock" operation for file "main.fdb"\n- Database already opened with engine instance, incompatible with current', -902, 335544344) 

I have already tried many different variations, but there is no result. Connecting to the database occurs directly to the file, not through the network. When I stop the daemon, the web works fine, that is, selects from the database work fine. If the daemon is started, the webcam does not work again.
I would be happy to work example, how can this be implemented.
Thank!

update: I tried to adjust the database isolation level in the following way:

 from fdb.fbcore import ISOLATION_LEVEL_READ_COMMITED_LEGACY class TPBAlchemy(SQLAlchemy): def apply_driver_hacks(self, app_, info, options): if 'isolation_level' not in options: options['isolation_level'] = ISOLATION_LEVEL_READ_COMMITED_LEGACY return super(TPBAlchemy, self).apply_driver_hacks(app_, info, options) 

And instead of:

 db = SQLAlchemy() 

Wrote:

 db = TPBAlchemy() 

But this only gave rise to another error:

 TypeError: Invalid argument(s) 'isolation_level' sent to create_engine(), using configuration FBDialect_fdb/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components. 

    2 answers 2

    Firebird under the nixes stores the lok files in the / tmp / firebird folder or where you specify the FIREBIRD_LOCK environment variable. The user, under which the executable module is launched, must have access to the level of creating / changing files in this folder.

    • Everything starts under the root. I know that not sekurno, but this is not production, so far so far without a difference. - Eugene
    • > Database already opened with engine instance, incompatible with current. Try to erase all lock-files. - user239133
    • Well, after that it works, until a new lock-file is created. - Eugene
    • Try adding the user, under which it all starts, to the firebird group. - user239133
    • It will be possible to try. Well, I think that the problem is not that. I rewrote everything to pure SQL and use fdb. Before each request I open a new connection, and after that I close it. Thus there are no locks. Even ISOLATION_LEVEL did not help, therefore one connection cannot be used. - Eugene

    What is the connection string in the web application and in the daemon? Probably just the full name of the database (or alias from the aliases.conf file), and not something like host: databasename or \ host \ databasename? If yes, then specify both there and there the connection string xnet: // databasename

    The project probably used to work with Firebird 2.5 or earlier. There, simply connecting by file name meant connecting to the Firebird server via the local XNET protocol. But in 3.0, simply connecting by file name means Embedded-mode, that is, each application is itself a database server. The one who managed to connect first, he got the base exclusively. And to work through XNET, you now need to explicitly specify the protocol in the connection string.

    PS You probably have linux? then XNET will not work, you need TCP / IP. The connection string must be inet: // databasename