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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litestar_asyncpg-0.5.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litestar_asyncpg-0.5.0.tar.gz
  • Upload date:
  • Size: 133.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for litestar_asyncpg-0.5.0.tar.gz
Algorithm Hash digest
SHA256 48d75bd6c5dbbd0701ce0632d3af1472a759caa56ec2ae0110b8319f74014abd
MD5 ce0f06662c294ec10f2406961550ff47
BLAKE2b-256 1c6e75a7951ae621caf7dd44bc20a8fa7ef63ba80f704007d94a7e96f2deac1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_asyncpg-0.5.0.tar.gz:

Publisher: publish.yaml on litestar-org/litestar-asyncpg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for litestar_asyncpg-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27180ff4b8338b6a74595b21fae9aaef4985688b40169d5b1862391e20b2b4e5
MD5 63aff28f984285f803c66967810409a8
BLAKE2b-256 6f1c1150bfb9dbcb9149ea8767f29b36919cf576e654115518ae12fae29cbb73

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_asyncpg-0.5.0-py3-none-any.whl:

Publisher: publish.yaml on litestar-org/litestar-asyncpg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page