Laboro Database module
Project description
gitea: none include_toc: true
laboro_database
This is the Laboro database module. Its purpose is to provide a simplified interface to all major relational database types.
It supports:
- PostgreSQL
- SQLite3
- MySQL
This module is intended to be used by the Laboro is a NO-Code / Low-Code workflow manager.
Classes
Public classes provided by this package:
-
Class:
DatabaseModule:
laboro_databasePackage:
laboro_databasePurpose: The
laboro_database.Databaseclass provides a simplified interface to all major relational database types.Arguments:
Name Type Required Implies Exclude Secret Default usernamestr False - serviceTrue None passwordstr False - serviceTrue None hoststr False - serviceFalse None portint False - serviceTrue None databasestr False - serviceFalse None servicestr False - host
-port
-username
-password
-databaseFalse None db_typestr True False Notes:
- The
db_typeargument must be one ofpgsql,sqliteormysql. - The
serviceargument is used for Postgesql services can be used only withdb_typeset topgsql(see PotsgreSQL connection service file for further details). - When
db_typeis set tosqlite:username,password,host,portandserviceare not used- the
databaseargument must be the full file path to the Sqlite3 database.
Instantiation examples:
-
Postgresql
packages: - laboro_database instances: - name: management_database module: laboro_database class: Database args: username: $crypt$gAAAAABi6IOvYj8lRMA76rCafoRBwjUk1SyHdCI0avhUyGsSUMHWhQw--nmJZSabdiKoQW4Yb4il6xtpB1jGdGqaNwmP0Lfn4A== password: $crypt$gAAAAABi6IOcLbBd1eAENaz8akV7yOagHxKyxlDATAkgcLHucD-uEHaZm-P7Ox1EN-6pkbEjm5lDFbkd860-kwgo-qT_qjM1QA== host: pgsql.example.com port: 5432 database: management db_type: pgsql
-
Sqlite3
packages: - laboro_database instances: - name: users_database module: laboro_database class: Database args: database: /opt/laboro/workspaces/my_workflow/users.db db_type: sqlite
Methods provided by class
laboro_database.Database:-
Name:
queryPurpose: This method allow to query the database.
Arguments:
Name Type Required Implies Exclude Secret Default requeststr True False paramsdict False False commitbool False False verbosebool False False False exit_on_errorbool False False True Notes:
- The
requestargument is a string that support variable substitution with named parameters. The variable substitution syntax depends on the chosendb_type. - The
paramsdictionary may contain more parameters than needed but must at least contain all needed parameters to fullfil therequeststring. - The
commitargument should be set toTruewhen the specifiedrequestinsert, update, delete database records.
Method call examples:
-
Postgresql
actions: instances: - name: users_database module: laboro_database class: Database args: service: users_database db_type: pgsql methods: - instance: users_database name: query args: request: select lastname, givenname, password from managers where role = %(role)s params: role: admin output: admins_info
-
Sqlite3
actions: instances: - name: users_database module: laboro_database class: Database args: database: /opt/laboro/workspaces/my_workflow/users.db db_type: sqlite methods: - instance: users_database name: query args: request: select lastname, givenname, password from managers where role = :role params: role: admin output: admins_info
-
Mysql
actions: instances: - name: users_database module: laboro_database class: Database args: username: $crypt$gAAAAABi6IOvYj8lRMA76rCafoRBwjUk1SyHdCI0avhUyGsSUMHWhQw--nmJZSabdiKoQW4Yb4il6xtpB1jGdGqaNwmP0Lfn4A== password: $crypt$gAAAAABi6IOcLbBd1eAENaz8akV7yOagHxKyxlDATAkgcLHucD-uEHaZm-P7Ox1EN-6pkbEjm5lDFbkd860-kwgo-qT_qjM1QA== host: mysql.example.com port: 3306 database: users db_type: mysql methods: - instance: users_database name: query args: request: select lastname, givenname, password from managers where role = %(role)s params: role: admin output: admins_info
- The
-
Name:
multi_queryPurpose: This method allow to execute a query multiple times with different parameters.
Arguments:
Name Type Required Implies Exclude Secret Default requeststr True False paramlistlist False False commitbool False False verbosebool False False exit_on_errorbool False False Notes:
- The
requestargument is a string that support variable substitution with named parameters. The variable substitution syntax depends on the chosendb_type. - The
paramlistis a list of dictionaries. Each dictionary in the list will be used once at a time with therequeststring. Each dictionary may contain more parameters than needed but must at least contain all needed parameters to fullfil therequeststring. - The
commitargument should be set toTruewhen the specifiedrequestinsert, update, delete database records. When set toTrue, a commit statement is sent to the database after each request.
Method call examples:
methods: - instance: users_database name: multi_query args: request: select lastname, givenname, password from managers where role = %(role)s paramlist: - role: admin - role: user output: admins_and_users_info
- The
-
Name:
transactionPurpose: Prepare and execute as a single transaction multiple queries on the database.
Arguments:
Name Type Required Implies Exclude Secret Default requestslist True False verbosebool False False exit_on_errorbool False False Notes:
- The
requestsargument is a list of 2 keyed dictionaries specifying a single request string (query) and its parameters (params) as described at theDatabase.querymethod. - If one of the queries defined in the
requestsargument fail, all requests within the transaction are roll backed.
Method call examples:
methods: - instance: users_database name: transaction args: requests: - query: select lastname, givenname, password from managers where role = %(role)s params: - role: admin - query: update role from managers set role = %(new_role)s where role = %(old_role)s params: - old_role: user - new_role: admin
- The
- The
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file laboro_database-0.0.7.tar.gz.
File metadata
- Download URL: laboro_database-0.0.7.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f79c70157f751c83a6b8d27d9eaf787548fd239eb99e5326934c3444dc4f3c3
|
|
| MD5 |
540725adcf324aeccdbbed60485b7687
|
|
| BLAKE2b-256 |
302516e526e9841c85770b801a5f5bf67af5f24c45ce6d92a99f92384ef4d94b
|
File details
Details for the file laboro_database-0.0.7-py3-none-any.whl.
File metadata
- Download URL: laboro_database-0.0.7-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc6ab81f49664a56d70c2dc53744eed96e9db9d3ec613f130e8a11d34cb1cad3
|
|
| MD5 |
b682df6d47bcefd9efc100904d3577e8
|
|
| BLAKE2b-256 |
4d89a61359a0074b41f9da897a76a3e5917d57cdf46d0850548d1f1231877ebd
|