mydb
mydb is a simple db wrapper for mysql.
Install
pip install mydb
Usage
Single Connection
from mydb.connection import Connection
db = Connection("mysql://youngking@localhost:13306/mydatabase")
for article in db.query("SELECT * FROM articles"):
print article.title
Multiple Connection Like Master/Slave
from mydb.router import ConnectionRouter
from mydb.proxy import DBProxy
router = ConnectionRouter(["myapp.somewhere.MasterSlaveRouter"])
db = DBProxy(router)
for article in db.query("SELECT * FROM articles"):
print article.title
Database routers
A database Router is a class that provides up to two methods:
db_for_read(statement, **hints)
Suggest the database that should be used for read operations for ``SELECT`` statement. If a database operation is able to provide any additional information that might assist in selecting a database, it will be provided in the hints dictionary. Details on valid hints are provided below. Returns None if there is no suggestion.
db_for_write(model, **hints)
Suggest the database that should be used for writes of statements except ``SELECT``. If a database operation is able to provide any additional information that might assist in selecting a database, it will be provided in the hints dictionary. Details on valid hints are provided below.
There is an example in tests/test_router.py.
A router doesn’t have to provide all these methods – it may omit one or more of them. If one of the methods is omitted, mydb will skip that router when performing the relevant check.
In mydb.router there are some default routers, where you can inherit from and overwriten them.
Links
Metadata
Release files for mydb 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mydb-0.1.2.tar.gz | 17.6 kB | Without provenance | Details |
Release files / mydb-0.1.2.tar.gz
| Download URL | mydb-0.1.2.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73b8d0ba5460f626990519db99846419f200925c2f178af873c81f156a591fa5
|
|
BLAKE2b-256 checksum How to use checksums |
2b37dde5ab43c033222c86c78676437c948c2330b148cf719bfc8850d9ab180d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for mydb 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.