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

Uploaded Source

Built Distribution

database_wrapper_pgsql-0.1.37-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.37.tar.gz
Algorithm Hash digest
SHA256 9f4c5bc022761546bc9a808e65819d86d6cb69808025f14c6d84929895b782c0
MD5 1433b3fba614f2952a21a903eab9d64f
BLAKE2b-256 1026003fb9ebcc9e563854c2ec0930c56c754998dec39e0e68276317c2afb830

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.37-py3-none-any.whl
Algorithm Hash digest
SHA256 e80a1c46b59110740763278a9cd12304e303374e7086e49c889a23c0d8e45843
MD5 d70c8d4608311331135c12cf1ec5ed80
BLAKE2b-256 04c74711c5e4fce57fa94e6dfc09b0a9012fbe9d60bf88e0a76d0120e9575d7b

See more details on using hashes here.

Provenance

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