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

Uploaded Source

Built Distribution

misery-0.4.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: misery-0.4.1.tar.gz
  • Upload date:
  • Size: 10.8 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.4.1.tar.gz
Algorithm Hash digest
SHA256 89b43dead590dd99e1385411d7aa98cd90269dd4643d90f1625edb6265cdb1a4
MD5 a4ea538f67bbe0048d1aa55f0f425e69
BLAKE2b-256 62576b9af8b41a964c8de84153d60b58679e2c5f7f52ba4e34fca435f304e96f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: misery-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 12.2 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.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f01c29b15824c67c33a308307802b90b0e08ee0ba21b96c20657235c4bd6e307
MD5 dcb29f47ed1357fdbfec1b2699b6f76d
BLAKE2b-256 274947ba12b96c6db536698796b3f3174c3a1e4e237223f9b1ced3d95b7e74cc

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