Database configuration¶
Genropy includes its own SQL mapper that allows you to operate transparently on several existing DBMSs. In fact, there are adapters for the different systems that allow you to access the database for reading and writing always using the same APIs defined by Genropy.
Currently, adapters to access databases have already been implemented
SQLite
postgreSQL
mySQL
msSQL
And others may be implemented in the future.
In this section we will see which additional components need to be installed and which configurations are necessary to operate your Genropy applications on the different DBMS.
Configure the instanceconfig¶
First of all, you need to appropriately configure the instanceconfig.xml
file which you will find in the config
directory of your application instance.
Inside the db tag you can insert the following parameters
implementation
: i.e. the DBMS of the database (postgres, sqlite, mysql, etc)dbname
: i.e. the name of the databasehost
user
password
port
extensions
: if you use extensions if necessaryhardQueryLimit
: allows a numeric hard limit threshold value for all queries executed by the application.
If you always use the same DBMS in your development environment and always work with the same connection parameters, you can define all these attributes in the instanceconfig/default.xml
file contained in the environment configurations.
To implement PostgreSQL, for example, you will need to modify the default.xml
file as follows:
<packages/>
<db implementation="postgres" host="localhost" user="postgres" password="postgres" port='5432' />
<authentication>
If you define these parameters in the default file, in the instanceconfig
file of your application you will only have to indicate the database name with the dbname
parameter.
Additional installations¶
Depending on the DBMS chosen, it will be possible to carry out the installation of Genropy using a particular profile among those possible. This way all libraries and dependencies will be installed automatically and you will therefore not need to install them manually.
For PostgreSQL¶
To be able to work with the Genropy SQL mapper on PostgreSql databases, the psql
profile is available which will automatically install the psycopg2 library.
Hint
If you are working in an macOS environment we suggest using Postgres.app as the version of PostgreSQL
But be careful with the $PATH! In case of problems please refer to this PostgreSQL Documentation
For MySQL¶
To be able to work with the Genropy SQL mapper on PostgreSql databases, the mysql
profile is available which will install the MySQL-python library.