Asyncpg plugin for Litestar
Project description
Litestar asyncpg
Installation
pip install litestar-asyncpg
Usage
Here is a basic application that demonstrates how to use the plugin.
from __future__ import annotations
from typing import TYPE_CHECKING
from litestar import Controller, Litestar, get
from litestar_asyncpg import AsyncpgConfig, AsyncpgPlugin, PoolConfig
if TYPE_CHECKING:
from asyncpg import Connection
class SampleController(Controller):
@get(path="/sample")
async def sample_route(self, db_connection: Connection) -> dict[str, str]:
"""Check database available and returns app config info."""
result = await db_connection.fetch("select 1")
return {"select_1": str(result)}
asyncpg = AsyncpgPlugin(config=AsyncpgConfig(pool_config=PoolConfig(dsn="postgresql://app:app@localhost:5432/app")))
app = Litestar(plugins=[asyncpg], route_handlers=[SampleController])
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
litestar_asyncpg-0.1.1.tar.gz
(72.3 kB
view hashes)
Built Distribution
Close
Hashes for litestar_asyncpg-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b593570e80e5f146513e7c7964ba6695d51bdf4885295c586727ccfb0769b31 |
|
MD5 | 414fc945e7da70aad30c5ef958e6783b |
|
BLAKE2b-256 | 2b3e2b2cd4850d3ebe175fc4bfd771cd9975768cc4a3b3443c84cdfdce5754bb |