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

Uploaded Source

Built Distribution

database_wrapper_pgsql-0.1.38-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.38.tar.gz
Algorithm Hash digest
SHA256 8b614df37c9ce760c6ee605ccfe6b0bf3003e1d0f1ff90098597ea3bfa305942
MD5 6384056a3800ef27676f40c78497c9a9
BLAKE2b-256 6cd9eb6f3f67c3748bc61bdb4d5a4c94b4ab214fd08a439b97d3c1c94aaa60d5

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.38-py3-none-any.whl
Algorithm Hash digest
SHA256 e640844c9c1aca8d16e929aaa627c1180920180f99147d7b269a010415329633
MD5 c1b7683b5da1907aef0db81005c4bbf0
BLAKE2b-256 c07d36f26e28c1a341cb349be5f85c9a5b188450c23a36a23b5485c39b733d43

See more details on using hashes here.

Provenance

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