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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file database_wrapper_mysql-0.1.37.tar.gz
.
File metadata
- Download URL: database_wrapper_mysql-0.1.37.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa64b16d802560becb8c7b24e9019dab5d95aa25fc2f936057a659c616b75a2c |
|
MD5 | e9fe8d73ec0a6e2df159ea28f3308a3a |
|
BLAKE2b-256 | e8f20ee1af6e96f4466c48f4ff424c1d3f52a7e7f0b1404d131cf5daef1c9c46 |
Provenance
The following attestation bundles were made for database_wrapper_mysql-0.1.37.tar.gz
:
Publisher:
master.yml
on gintsmurans/py_database_wrapper
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
database_wrapper_mysql-0.1.37.tar.gz
- Subject digest:
fa64b16d802560becb8c7b24e9019dab5d95aa25fc2f936057a659c616b75a2c
- Sigstore transparency entry: 148238815
- Sigstore integration time:
- Predicate type:
File details
Details for the file database_wrapper_mysql-0.1.37-py3-none-any.whl
.
File metadata
- Download URL: database_wrapper_mysql-0.1.37-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd08774f570e2229131f1a00f1311f8e1ed9f2601b923f6716746757231c37a8 |
|
MD5 | 69bfe8ea7e87a99460af3fe2e7c71874 |
|
BLAKE2b-256 | a5983233eb6c298772a9b5b988fd382ad20f1a0d02e6b36ea7463fd7b047e153 |
Provenance
The following attestation bundles were made for database_wrapper_mysql-0.1.37-py3-none-any.whl
:
Publisher:
master.yml
on gintsmurans/py_database_wrapper
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
database_wrapper_mysql-0.1.37-py3-none-any.whl
- Subject digest:
fd08774f570e2229131f1a00f1311f8e1ed9f2601b923f6716746757231c37a8
- Sigstore transparency entry: 148238821
- Sigstore integration time:
- Predicate type: