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.5.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

misery-0.5.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file misery-0.5.0.tar.gz.

File metadata

  • Download URL: misery-0.5.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.3 Darwin/19.4.0

File hashes

Hashes for misery-0.5.0.tar.gz
Algorithm Hash digest
SHA256 da0d2fd00c12aa51a78892353f65898e0371385e8bb03b762a896dfab2eaa329
MD5 b8ce978f5e169a031fae2513d7688104
BLAKE2b-256 59495813819ac427cda6ff1c9775d74e613d871fe0040c719d2be64174dcf231

See more details on using hashes here.

File details

Details for the file misery-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: misery-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.3 Darwin/19.4.0

File hashes

Hashes for misery-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2bdc3b2fb78de38c0ac0ae61c96e33d8a5bda48b8a4ead279b166c0dfc647c1b
MD5 6d9730f9e985b34bb7f7ed4d469efa40
BLAKE2b-256 64024359987f7041805e052a70f88ef0d7ae2132a76827fca562cb65b74bab1d

See more details on using hashes here.

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