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 databases.

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.28.tar.gz
Algorithm Hash digest
SHA256 93b28fa35684719ce28ffaab8c4e168cea5921e76885ffd00a4792092754a19e
MD5 81a9231327ef0bc4fab3a39099f0dc36
BLAKE2b-256 f4f4619fd964e4aa3d6aca6b2e23666d9ac5dc8e795a9575ed447e1a94220fe9

See more details on using hashes here.

Provenance

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

Publisher: master.yml on gintsmurans/py_database_wrapper

Attestations:

File details

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

File metadata

File hashes

Hashes for database_wrapper_mysql-0.1.28-py3-none-any.whl
Algorithm Hash digest
SHA256 eef81e50c644870a3cf8b3ddd5f262893e3e354341cc9d7f8bb1df14aaa3b8a8
MD5 861f8c3d97eb469b13e7fab2ec36449c
BLAKE2b-256 33a7aa64eb0d639269f22d4da91bf1385a0f3acb9ebc73e0415cbdbff15dd50a

See more details on using hashes here.

Provenance

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