Implement basic CRUD operations into DataObject framework with generalized DB access.
Project description
db-able
Framework to implement basic CRUD operations with DB for DataObject.
Quick start
Set up your connection string to your database.
from db_able import client
client.CONN_STR = '{dialect}+{driver}://{username}:{password}@{host}:{port}/{database}?{query_args}'
Implement the mixins into your DataObject to inject CRUD methods.
from do_py import R
from db_able import Creatable, Deletable, Loadable, Savable
class MyObject(Creatable, Deletable, Loadable, Savable):
db = '{schema_name}'
_restrictions = {
'id': R.INT,
'key': R.INT
}
load_params = ['id']
create_params = ['key']
delete_params = ['id']
save_params = ['id', 'key']
my_obj = MyObject.create(key=555)
my_obj = MyObject.load(id=my_obj.id)
my_obj.key = 777
my_obj.save()
my_obj.delete()
Classmethods create
, load
, and methods save
and delete
are made available
to your DataObject class.
Use provided SQL Generating utils to expedite implementation.
from db_able.utils.sql_generator import print_all_sps
from examples.a import A
print_all_sps(A)
Testing & Code Quality
Code coverage reports for master, branches, and PRs are posted here in CodeCov.
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
db-able-1.0.1.tar.gz
(12.2 kB
view details)
Built Distribution
db_able-1.0.1-py3-none-any.whl
(18.6 kB
view details)
File details
Details for the file db-able-1.0.1.tar.gz
.
File metadata
- Download URL: db-able-1.0.1.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60ae42a8722173403cc349dcecc344e8e5dae25e82851e97cec8cc7be83dfcd7 |
|
MD5 | 09290a3d0b8635a31e48bb139efdae30 |
|
BLAKE2b-256 | 6c6236208144c33687bf37b80114e67b34ab209ac781a69b09fbdb056b9a3b48 |
File details
Details for the file db_able-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: db_able-1.0.1-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f6ecaa4614f41a85efd8c799184772f0ff83112345aea36f6ff850515eaa34a |
|
MD5 | 7730cc10c53eccb2d8292f4b12f45fff |
|
BLAKE2b-256 | d723eed39f57a0cad0ff3e22613c364bd15021f6b7b9272469f6496645edbf08 |