Could flask and owlready2 use the same SQLite database at the same time?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Could flask and owlready2 use the same SQLite database at the same time?

billwang
I am currently working on a flask web project and trying to add owlready2 to this project.

My flask project is using SQLite (more specific, SQLAlchemy) as the default database. From my understanding, owlready2 also maintains an RDF quadstore in an optimized database (SQLite3).

My question is, could owlready2 and flask use the same SQLite database at the same time? Since I heard about there is a "multiple connections error" in flask.
Reply | Threaded
Open this post in threaded view
|

Re: Could flask and owlready2 use the same SQLite database at the same time?

Jiba
Administrator
Hi,

Since the database for Flask and Owlready2 will be used by the same process, I think it is possible to use the same database, in theory. However, you need to synchronize the access to the database if there are several process (depending on the underlying web server).

Nevrtheles, I recommend to use to separate database. Since there are no shared table/data, there is no interest in having a single database, except that it needs 2 files instead of one. In addition, Owlready synchronize the database write access automatically when you use the "with ontology:..." blocks, so process synchronization should be Ok for that database. For the other database, it is up to you (or SQLAlchemy) to d the synchronization.

Also notice that Owlready can advantageously replace an ORM like SQLAlchemy. In particular, performance are often better with Owlready, due to optimization of the quadstore.

Jiba