Skip to main content

database_wrapper for MySQL database

Project description

database_wrapper_mysql

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

Uploaded Source

Built Distribution

database_wrapper_mysql-0.1.42-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.42.tar.gz
Algorithm Hash digest
SHA256 26a1a61b58d1ef003546efe9ed4e438b0df2224434c50a8e773d1149bd53e6aa
MD5 1a570df704d8c77038ca8da709f33043
BLAKE2b-256 2c7be1582e55a64d3ed29fd237620ce0f63341a675574697f2a0122f1bfbeb3c

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.42-py3-none-any.whl
Algorithm Hash digest
SHA256 6089fe316a30bf68140dcebae421dcfeb957b5942f33810ff928adb535ea0a0a
MD5 0fb8068b6834960fb0edb6dc46257e29
BLAKE2b-256 d58b803f3ade03e2a046b3feb409e8475f894d56b981907a9b8eb337273f1364

See more details on using hashes here.

Provenance

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