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

Uploaded Source

Built Distribution

database_wrapper_pgsql-0.1.42-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.42.tar.gz
Algorithm Hash digest
SHA256 f7fdda12f52a2a42f6a6dffc358ac4c21b94f4b0fbefe741e8b9110aaf3f53eb
MD5 c9fd835c3e84d000e141214a7c565012
BLAKE2b-256 8ba759b53cf1bc381d226b123226d219c52109f9b2bf9114a7f6e697c9d6bf78

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.42-py3-none-any.whl
Algorithm Hash digest
SHA256 11fd46012d6f1899dbc5e137a96aacbc092d96115753846a4e35ad812fc35ba3
MD5 26368ef68175f3d1531c3a3256042027
BLAKE2b-256 87184ced82b0292ae132337c0d363b58f57b6c83bcb56641778fdc8371641e75

See more details on using hashes here.

Provenance

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