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 AsyncPgSQLWithPooling, DBWrapperPgSQL

db = MySQL({
    "hostname": "localhost",
    "port": 3306,
    "username": "root",
    "password": "your_password",
    "database": "my_database"
})
db.open()
dbWrapper = DBWrapperMySQL(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,
    """
        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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

database_wrapper_pgsql-0.1.29-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_pgsql-0.1.29-py3-none-any.whl
Algorithm Hash digest
SHA256 a54fa928359f2b56cf9d597ac3620cd53bef6ca8f89d09e1d183ef5b9e6a2181
MD5 db98f8d44d91509a26fe5420792c5c85
BLAKE2b-256 e498992dc000cdcd5f324e911e0f82feb4499dc003e7cfdf805a37054ff49742

See more details on using hashes here.

Provenance

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