A simple set of Posgres DB utilities
Project description
mar-db_utils
Description
This is a library that contains a set of functions that can be used to interact with a databases. Currently, the library only supports PostgreSQL. To use, instantiate the PgDbOps class and pass in the database name, user, password, port, and sslmode as arguments.
The PgDbOps class has the following methods:
- connect_db
- This method connects to the database and returns a connection object.
- close_db
- This method closes the database connection.
- sqlrun
- This method runs a single SQL statement.
- runinsmultiples
- This method runs a single SQL statement multiple times.
- runbulkinsert
- This method runs a bulk insert SQL statement.
- insert_data
- This method inserts data into a table. This method uses sqlrun to run the SQL statement.
- update_data
- This method updates data in a table. This method uses sqlrun to run the SQL statement.
- delete_data
- This method deletes data from a table. This method uses sqlrun to run the SQL statement.
- select_data
- This method selects data from a table.
Setup
Create a virtual environment Activate the virtual environment Install the following libraries:
- psycopg2-binary
- pystest
- python-dotenv
Create a .env file and add the following:
- DB_NAME
- DB_USER
- DB_PORT
- DB_SSLMODE
- DB_PASSWORD
Project details
Release history Release notifications | RSS feed
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 mar-db_utils-0.2.tar.gz.
File metadata
- Download URL: mar-db_utils-0.2.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7160437a00fbd2c3732d581fc062ca354265e2997d8c56d7e65714888e4d980
|
|
| MD5 |
a91a96614b8dda109646acbd6a1ad74e
|
|
| BLAKE2b-256 |
31269f3bd6ebfe276457f0ad3b7752e665395f7ab0541da25b4cb34fb3067200
|
File details
Details for the file mar_db_utils-0.2-py3-none-any.whl.
File metadata
- Download URL: mar_db_utils-0.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a32244654eabe33cf88ab66669a3e93a879cc13735c193ea503ffac2364948c5
|
|
| MD5 |
fa582ceb92feff601b6c3a7ead36bd31
|
|
| BLAKE2b-256 |
de64279e689448dae6950e64f7f6543002ea1642b16e4d77a57cda7132d674c5
|