Skip to main content

database_wrapper for MySQL database

Project description

database_wrapper

Part of the database_wrapper package.

This python package is a database wrapper for MySQL and MariaDB database.

Installation

pip install database_wrapper[mysql]

Usage

from database_wrapper_mysql import MySQL, DBWrapperMySQL

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,
    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_mysql-0.1.32.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

database_wrapper_mysql-0.1.32-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.32.tar.gz
Algorithm Hash digest
SHA256 adf03fe9fa3b00aa8335bf21be8380a963e13b56137ae582e2dfacd86d7f7a90
MD5 f42f5793e25d0d1e8c8f0f416fa83950
BLAKE2b-256 d57f113f7134b31c3294d59e082ba4ae78f3fdfa19012837a346a2104d9309e4

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.32-py3-none-any.whl
Algorithm Hash digest
SHA256 7b466bc5cddf7f9e459e62e5290d1f0edad8fe608f4f74909fa807fb75b18abe
MD5 abe76274972c6a24c2fa5e162738f264
BLAKE2b-256 944a063472ea44265976fad16b7b34db79138baf2599a6e93b98bbe0ae4d9a02

See more details on using hashes here.

Provenance

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