Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basalam_backbone_orm-2.0.14.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basalam_backbone_orm-2.0.14-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file basalam_backbone_orm-2.0.14.tar.gz.

File metadata

  • Download URL: basalam_backbone_orm-2.0.14.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for basalam_backbone_orm-2.0.14.tar.gz
Algorithm Hash digest
SHA256 8d5bf5046b2368a015a844c30f7e40f2a0db5325ada1712831b4b425fe32a13d
MD5 ce9416daaedca409c97c62a5f89a773e
BLAKE2b-256 5c5b230ce2a39d40114148c3760d66557906e6e9d08a2cd271b871011b64ebbd

See more details on using hashes here.

File details

Details for the file basalam_backbone_orm-2.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for basalam_backbone_orm-2.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 87fb90d9506bb59392e5e22e8f789c52f82f6b0e54fb5e4e4dcf5540548cc4b3
MD5 5aa19e9b9de9be036609a74bc90e6b56
BLAKE2b-256 580716f917ca3425e2526e08c290c92c63c182b2705e076bb2a8f4fcc3d22826

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page