CuteHMI - Shared Database (CuteHMI.SharedDatabase.0)
|
This extension acts as shared database provider. The intent of this extension is to provide database connections, which live in dedicated database threads, but can be shared across different extensions. Below is a brief description of classes, which help to accomplish this.
Class cutehmi::shareddatabase::Database is responsible for configuring and maintaining database connection that lives in dedicated thread. From QML (import CuteHMI.SharedDatabase.0
) it is available as Database component.
cutehmi::shareddatabase::DatabaseWorker is a convenient class that allows one to run SQL-specific code in the dedicated database thread.
In order to make this extension work you need Qt SQL module and appropriate client library as explained in Qt documentation on SQL Database Drivers. For development purposes you can copy library files to deploy/lib
subdirectory of external folder. This is handy especially on Windows.
Extension provides cutehmi::shareddatabase::Console component, which can be used with cutehmi.console.0 tool.
This component allows for some very basic database operations. You can check out whether connection works by setting properties on db
object. For example below is a typical default PostgreSQL configuration.
Connection can be tested by starting the service.
In case of error different notification is shown.
Once connection is established one can create PostgreSQL database.
One can use JavaScript object to specify parameters after WITH
keyword.
Database can be dropped in a similar way.