Skip to main content

database_wrapper for PostgreSQL database

Project description

database_wrapper

Part of the database_wrapper package.

This python package is a database wrapper for PostgreSQL (also called pgsql) database.

Installation

pip install database_wrapper[pgsql]

Usage

from database_wrapper_pgsql import PgSQLWithPoolingAsync, DBWrapperPgSQLAsync

db = PgSQLWithPoolingAsync({
    "hostname": "localhost",
    "port": 3306,
    "username": "root",
    "password": "your_password",
    "database": "my_database"
})
db.open()
dbWrapper = DBWrapperPgSQLAsync(db=db)

# Simple query
aModel = MyModel()
res = await dbWrapper.getByKey(
    aModel,
    "id",
    3005,
)
if res:
    print(f"getByKey: {res.toDict()}")
else:
    print("No results")

# Raw query
res = await dbWrapper.getAll(
    aModel,
    customQuery="""
        SELECT t1.*, t2.name AS other_name
        FROM my_table AS t1
        LEFT JOIN other_table AS t2 ON t1.other_id = t2.id
    """
)
async for record in res:
    print(f"getAll: {record.toDict()}")
else:
    print("No results")

db.close()

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

database_wrapper_pgsql-0.1.33.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

database_wrapper_pgsql-0.1.33-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file database_wrapper_pgsql-0.1.33.tar.gz.

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.33.tar.gz
Algorithm Hash digest
SHA256 82c9b46bca6e4a7a19a8f10ea467194d5fd080921e574e18a47a5711c81214b3
MD5 77269309ad9280ef2ec42cc95791aec1
BLAKE2b-256 4d83d0287266a10aeaeed149802cef0b303e8b40c8db447ecd399c49e5d096bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for database_wrapper_pgsql-0.1.33.tar.gz:

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

Details for the file database_wrapper_pgsql-0.1.33-py3-none-any.whl.

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.33-py3-none-any.whl
Algorithm Hash digest
SHA256 1c8f5f515f00a9f78cde6915fb7098b7caa35446a7de785137fb250961daa7d8
MD5 06594ef111c147745c1446e4ac020b36
BLAKE2b-256 6472f34783685aae9b553c59a7a3fbde0b8c76eab5743a418f1ea57e3af79b8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for database_wrapper_pgsql-0.1.33-py3-none-any.whl:

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page