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

Uploaded Source

Built Distribution

database_wrapper_mysql-0.1.33-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.33.tar.gz
Algorithm Hash digest
SHA256 335b58164ec1d5ea14e9cb283bbc70cfd62971877973d865d2584b29f4666335
MD5 3bb00df475f0652046dad2eabb653977
BLAKE2b-256 c9fed301dac81919cea58e1111355330c26274dd7bfc4a2ecc1fb52976dba552

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.33-py3-none-any.whl
Algorithm Hash digest
SHA256 5223fd0fee1bdd11121018a37c58471b4213c693eda65bcbf640fc3c8a68008a
MD5 4c6e486386464b81cbffc98b87b3edf0
BLAKE2b-256 5df7eadd98a25dc05048885a98f21ee7852f83e79c2b7189984685b92485019b

See more details on using hashes here.

Provenance

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