Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meowmeowcode/misery
asyncio-friendly database toolkit
https://github.com/meowmeowcode/misery
asyncio clickhouse databases postgresql python
Last synced: about 2 months ago
JSON representation
asyncio-friendly database toolkit
- Host: GitHub
- URL: https://github.com/meowmeowcode/misery
- Owner: meowmeowcode
- License: mit
- Created: 2022-04-18T18:03:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-04T07:07:30.000Z (over 1 year ago)
- Last Synced: 2024-11-06T03:51:32.301Z (about 2 months ago)
- Topics: asyncio, clickhouse, databases, postgresql, python
- Language: Python
- Homepage:
- Size: 168 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```python
from dataclasses import dataclass
from uuid import UUID, uuid4import asyncpg
from pypika import Table
from misery.postgres import PostgresRepoconn = 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: strclass 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
```