Skip to main content

A modest orm that does not require you to adjust your code to it

Project description

DBCore Python 3.12+ License:MIT PyPi version

ORM that does not require the developer to create models specifically for it. dbcore works with dataclasses and allows you to connect from one interface to both local databases (sqlite+aiosqlite) and remote databases (postgres+asyncpg).

Small example

import os
import asyncio
from dataclasses import dataclass

from aiodbcore import AsyncDBCore


# a model in which only the id field gives out DB membership
@dataclass
class MyModel:
    id: int | None = None
    foo: int = 0
    bar: str = ""


class MyDB(AsyncDBCore[MyModel]):
    # there i can implement my queries
    async def my_simple_query(self) -> list[MyModel]:
        return await self.fetchall(MyModel, where=MyModel.foo > 10)


async def main():
    MyDB.init(os.environ["DB"])  # init db at start of program
    db = MyDB()
    data = await db.my_simple_query()
    first = data[0]
    first.foo += 100
    await db.save(first)
    await db.close_connections()


if __name__ == '__main__':
    asyncio.run(main())

The declaration of the model from the example above is certainly simple and elegant, but this method does not allow the IDE to show type hints, and static typers will complain. Therefore, there is another way to declare models, it will require minimal changes in the code.

from dataclasses import dataclas
from aiodbcore.models import Field

@dataclass
class MyModel:
    # Here you can wrap default values in `Field`
    # if you don't want complaints from static typers,
    # but it is not necessary
    id: Field[int | None] = Field(None)
    foo: Field[int] = 0
    bar: Filed[str] = ""

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

aiodbcore-0.1.2.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

aiodbcore-0.1.2-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file aiodbcore-0.1.2.tar.gz.

File metadata

  • Download URL: aiodbcore-0.1.2.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for aiodbcore-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f6664ea3f74ef884f9995ca456680aa70a2e800ccdb062b6b4a22c5ed88e57fc
MD5 1dce847b264a9861ae9654ae97393150
BLAKE2b-256 5d80a78d902223341cf0a75637e0d27590a1d097c12b7d88db50d6bd1b8556af

See more details on using hashes here.

File details

Details for the file aiodbcore-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: aiodbcore-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for aiodbcore-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a7170884351326ac2295c34fc585a6f8caedc411684e3b078b9005cb820946c5
MD5 ad74a9b2ce3b551747378d9dc77d8cdc
BLAKE2b-256 93cee2274363d427bf877e36caeaf218a5f4a1f83e54c4c3d252f493551dc998

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