Skip to main content

asyncio-friendly database toolkit

Project description

misery

Misery

An asyncio-friendly database toolkit that works well with MyPy.

Supported database systems

At the moment, PostgreSQL and ClickHouse are supported.

Documentation

The latest documentation: https://misery.readthedocs.io

Usage example

from dataclasses import dataclass
from uuid import UUID, uuid4

import asyncpg
from pypika import Table
from misery.postgres import PostgresRepo


conn = await asyncpg.connect("postgresql://postgres:password@localhost/postgres")

await conn.execute(
    """
        CREATE TABLE users (
            id uuid PRIMARY KEY,
            name text NOT NULL UNIQUE
        );
    """
)


@dataclass
class User:
    id: UUID
    name: str


class UsersRepo(PostgresRepo[User]):
    table = Table("users")


users_repo = UsersRepo(conn)

user_id = uuid4()
bob = User(id=user_id, name="Bob")
await users_repo.add(bob)

user = await users_repo.get(id=user_id)
assert user == bob

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

misery-0.7.0.tar.gz (11.5 kB view hashes)

Uploaded Source

Built Distribution

misery-0.7.0-py3-none-any.whl (13.0 kB view hashes)

Uploaded Python 3

Supported by

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