Skip to main content

database_wrapper for PostgreSQL database

Project description

database_wrapper_pgsql

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.44.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

database_wrapper_pgsql-0.1.44-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.44.tar.gz
Algorithm Hash digest
SHA256 9d45651dd9387aca0a12301ad57f396e0cb9955a4e9cb308988ea254e07ea2ef
MD5 566ab6432e994dca0937c4114bdf5199
BLAKE2b-256 e8245bce9eab2c3decf3172552aff26bf1e7a0c53405083b8d89626c6992a1ab

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.44-py3-none-any.whl
Algorithm Hash digest
SHA256 ba45100d92f960c9d75903557a7a6bae87b44abf0c8bdd0adcf786c870ffe287
MD5 29f69769c608b6ccfb44f25f671ec1df
BLAKE2b-256 5cab753da961585733d885e3e70c1be4023523d418a637c410956711a09f8c34

See more details on using hashes here.

Provenance

The following attestation bundles were made for database_wrapper_pgsql-0.1.44-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