Python Utilities & Basalam Micro-Services SDK
Project description
Requirements
- Python 3.6+
Installation & Upgrade
pip install backbone-orm
Usage
from backbone_orm import (
RepositoryAbstract,
PostgresManager,
DriverEnum,
ConnectionConfig,
ModelAbstract,
T,
Parameters
)
import aioredis
import typing
postgres = PostgresManager(
default=DriverEnum.POOL,
config=ConnectionConfig(...)
)
redis = aioredis.Redis(...)
class UserModel(ModelAbstract):
id: int
name: str
class UserRepo(RepositoryAbstract[UserModel]):
@classmethod
async def connection(cls) -> PostgresConnection:
return await postgres.acquire()
@classmethod
def redis(cls) -> aioredis.Redis:
return redis
@classmethod
def table_name(cls) -> str:
return "users"
@classmethod
def model(cls) -> typing.Type[T]:
return UserModel
@classmethod
def soft_deletes(cls) -> bool:
return True
@classmethod
def default_relations(cls) -> typing.List[str]:
return []
print(await UserRepo.find_by_id(1))
Testing
# install pytest
pip install pytest
# run tests
python -m pytest
Changelog
- 0.0.11 Now build and push are done using gitlab-ci
- 0.0.13 fix: return type of update_return
- 0.0.14 custom order enums
- 0.0.15 has_relations in ModelAbstract
- 1.0.0 Adds QueryBuilder, Adds Connection Manager
- 1.0.9 Extend QueryBuilderAbstract from pypika PostgreSQLQueryBuilder
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file basalam_backbone_orm-1.0.13.tar.gz.
File metadata
- Download URL: basalam_backbone_orm-1.0.13.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82f65b453be186937582eea453a9062337db87cdcc8dbbcaed24c29eefd06cc7
|
|
| MD5 |
e0a315529392f5f5962e0211263421e0
|
|
| BLAKE2b-256 |
8be6e0977815c7555cc2afc02573e8ec5524a1f5b873be84c745073db9922f98
|
File details
Details for the file basalam.backbone_orm-1.0.13-py3-none-any.whl.
File metadata
- Download URL: basalam.backbone_orm-1.0.13-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f18f077b68513e3a525a50d41e636bcd25b9fc2a2ba867abc560c875ea5980f1
|
|
| MD5 |
698bf1b5423438e74722ec064c9ee8f9
|
|
| BLAKE2b-256 |
7c3d157947b5c75030b928122046d1c23d42d1c06cc8733166a701ff3423889b
|