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

Uploaded Source

Built Distribution

database_wrapper_mysql-0.1.43-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.43.tar.gz
Algorithm Hash digest
SHA256 09689b67438c31aee2926bfcb74ee51d6e6e3e661b07d63cf00f026dfcbb0120
MD5 a330ec24a187e778c104509f82ee5e12
BLAKE2b-256 3f23d7217394293fb860e4dce51d45d824fd859fa3cf74fc05f7cfe9605e7f96

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.43-py3-none-any.whl
Algorithm Hash digest
SHA256 742ccdac5fd28174538de34c656aed3d2651bd78565df226792220a8fb4d4e63
MD5 825ae3f96873ee34b8338f382e29e856
BLAKE2b-256 44da56c9f1e4f0a2cf19e1bfca5103078e63d0bf0616e7982fd218e5ee2d8b75

See more details on using hashes here.

Provenance

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