asyncio-friendly database toolkit
Project description
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
Release history Release notifications | RSS feed
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 details)
Built Distribution
misery-0.7.0-py3-none-any.whl
(13.0 kB
view details)
File details
Details for the file misery-0.7.0.tar.gz
.
File metadata
- Download URL: misery-0.7.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.3 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e759ea32bd0ae0f9ff0372b9aa8de5766a80d6fd51d3551c1c9580d5ea47791b |
|
MD5 | 86818104426b8f6f8db088de18a728f1 |
|
BLAKE2b-256 | 8c282313974eb89f516f3d0f4024fbb1d82b5b259809f271faf3ae74b07ceb25 |
File details
Details for the file misery-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: misery-0.7.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.3 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcdec4cfc5666b3d68041a7dd216ed77f89396a82e6f965f2841c06ad91717ea |
|
MD5 | 33dc93c64c9f7190b1615c00ba4cf691 |
|
BLAKE2b-256 | b5261baaec2061ec9bdcd023b2f1e302dfa2b3c8b10c7a941b40a5cdd9ed737d |