Convenient wrapper to create database connection engine based on the parameters passed. This engine can be used to run sql queries on the respective databases.
Project description
Database connection creator
Convenient wrapper to create database connection engine based on the parameters passed. This engine can be used to run sql queries on the respective databases.
Install with pip
$ pip install DbConnection
Usage
-
Import the library.
from DbConnection.DbConnectionCreator import DbConnectionCreator
-
Create an instance.
sql_db_con = DbConnectionCreator(project_path="", logger=<your_logger_instance>, env="", db_library="").get_database_connection_object()
Arguments (all are mandatory):
project_path: Project name, which would serve as the logger's name (if specified), and the prefix for log filenames.logger: your Logger Instance"env": Execution Environment"env": select specifc library either 'sqlalchemy' and 'oracledb'
-
create a connection string
conn_string = sql_db_con.get_session_conn_string(self, test='local', co_name=None, schema=False, vault_cred_dict=None, local_creds_json_file_with_path=None, connection_keys_mapper_file_with_path=None)
Arguments (all are mandatory):
test: 'local' or 'deploy' which says whether to run in local or deployco_name: 'AZURE' or 'Postgres' or 'CRM'. returns the respective connection stringschema: pass False as value to establish connection only to database and not schemavault_cred_dict: dictionary which contains values read from vault secret pathslocal_creds_json_file_with_path: json file which contains credentials in the same format as vault secret valuesconnection_keys_mapper_file_with_path: json file contains the specific creds keys to use for each co_name
-
create an engine
conn_engine = sql_db_con.create_eng(conn_string)
Arguments (all are mandatory):
conn_string: connection string obtained in step 3
-
create a session
conn_session = sql_db_con.create_session(conn_string)
Arguments (all are mandatory):
conn_string: connection string obtained in step 3
Author
© 2022, Mallikarjuna Devaraya.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 DbConnection-0.0.4-py3-none-any.whl.
File metadata
- Download URL: DbConnection-0.0.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ddae1d4dd1b814cb4ce9e0af9e309cd2bf8627363329571a50bc81b446ae453
|
|
| MD5 |
9b8b9001c79cc025bbd9143f2fcd4fdb
|
|
| BLAKE2b-256 |
c662f11420e671b28d42ba7ddc63bce4e933f8eb084c37ef3d69cc42df8cda62
|