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"
})
await db.openPool()
try:
    async with db as (dbConn, dbCursor):
        dbWrapper = DBWrapperPgSQLAsync(dbCursor=dbCursor)

        # 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")

finally:
    await db.openPool()

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

Uploaded Source

Built Distribution

database_wrapper_pgsql-0.2.7-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: database_wrapper_pgsql-0.2.7.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for database_wrapper_pgsql-0.2.7.tar.gz
Algorithm Hash digest
SHA256 42bc5547655d0723d571fea05e7311a7798a0a19510ec464e92eea3ecbb2650c
MD5 4b808b2b39598883c56b7c844ed5adff
BLAKE2b-256 a48c38532d459d9dbefc3ef50d3cf85f48fc7201df68c81ac22806e425688b7c

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c8e2b6780a5689a356eec2fe2854681c746fcaf233ec0d9243074f806266a8f0
MD5 a4c537dc78c6213f254c6bd04209d8b1
BLAKE2b-256 b4ec319ce86383020d628da2b5366624ab7b93ade2bfb0e72032be04a58f4dd7

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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