Skip to main content

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])

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.4.0.tar.gz (128.1 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.4.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litestar_asyncpg-0.4.0.tar.gz
  • Upload date:
  • Size: 128.1 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.4.0.tar.gz
Algorithm Hash digest
SHA256 2ca2ffb8ea2839c2010f540cfe107bc7b412f83a0cb492c8fbea63c0914fb050
MD5 e9d13ce2e531d31dabe1f283ca54ea08
BLAKE2b-256 fc79a252d11043b1e77e105581dbacd1e28faa65ce1f07db4b4dc30fa54dcc1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_asyncpg-0.4.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.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for litestar_asyncpg-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c48b12a40dd631c107f18af4c4a6d3d57fc5dcbbf3f6ff60f4561fefb563dac
MD5 a6c431f2cf4042aa64dcb87202772028
BLAKE2b-256 6de28fe7aca205ec9d664b7c1abf57b623d129f57dfbd5a285d595b6c6327aeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_asyncpg-0.4.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.

Release history Release notifications | RSS feed

0.5.0

2 files

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page