Skip to main content

Asyncpg plugin for Litestar

Project description

Litestar Logo - Light Litestar Logo - Dark

Project Status
CI/CD Latest Release ci Documentation Building
Quality Coverage Quality Gate Status Maintainability Rating Reliability Rating Security Rating
Package PyPI - Version PyPI - Support Python Versions Advanced Alchemy PyPI - Downloads
Community Reddit Discord Matrix Medium Twitter Blog
Meta Litestar Project types - Mypy License - MIT Litestar Sponsors linting - Ruff code style - Ruff
# Litestar Asyncpg

A barebones AsyncPG plugin for Litestar. This plugin is useful for when you plan to use no ORM or need to manage the postgres connection separately.

Usage

Installation

pip install litestar-asyncpg

Example

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

Uploaded Source

Built Distribution

litestar_asyncpg-0.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file litestar_asyncpg-0.2.0.tar.gz.

File metadata

  • Download URL: litestar_asyncpg-0.2.0.tar.gz
  • Upload date:
  • Size: 66.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for litestar_asyncpg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f172cef33674571506d9a9f0a6184dc0da02b9529fc5ec810deb8b4b65d20d76
MD5 86ca0b6f8ccdee1d818680fab52e69a4
BLAKE2b-256 a756c69ff97377c7511dfcc8536401b98ae98ba79365ab16ac6ad51f9c396a5e

See more details on using hashes here.

File details

Details for the file litestar_asyncpg-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for litestar_asyncpg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4df589645da9ed965263ac158e97439db6beb5a5b1b1d63c7022697c88e15b42
MD5 2f26c0b19c45421ddedb272833e43e92
BLAKE2b-256 67400d556ca7ff8ffce11c70e84ffb5b6aac0e44ba358a53cdef33724e4cf309

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