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

Uploaded Source

Built Distribution

database_wrapper_pgsql-0.1.32-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.32.tar.gz
Algorithm Hash digest
SHA256 222cc9f17e7490f6a6de8f192462935c336f3a47cf7a7182dc830d881f589f73
MD5 52cec28cf12e27b8e3b4bec76b331419
BLAKE2b-256 b839dd568baf35a2f5c5f5adf5a9e39d9390f5804c50a86f5017c5e21bd18a06

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.32-py3-none-any.whl
Algorithm Hash digest
SHA256 ac10efeda86d6c3222686c7d8ac6037b56fa61ae4294a48441e7ab5e0ec782c1
MD5 4a458408f1f90f22e34a4858bc1356f1
BLAKE2b-256 c96e53246ad8776fec8a6a39faae836d72e4bd6c522ca56d9656daa7dd953d6b

See more details on using hashes here.

Provenance

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