Skip to main content

Oracle DB 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 Litestar OracleDB PyPI - Downloads
Community Reddit Discord Matrix Medium Twitter Blog
Meta Litestar Project types - Mypy License - MIT Litestar Sponsors linting - Ruff code style - Ruff
# Litestar - Oracle Database Plugin

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

Usage

Installation

pip install litestar-oracledb

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, Request, get

from litestar_oracledb import AsyncDatabaseConfig, AsyncPoolConfig, OracleDatabasePlugin

if TYPE_CHECKING:
    from oracledb import AsyncConnection


class SampleController(Controller):
    @get(path="/")
    async def sample_route(self, request: Request, db_connection: AsyncConnection) -> dict[str, str]:
        """Check database available and returns app config info."""
        with db_connection.cursor() as cursor:
            await cursor.execute("select 'a database value' a_column from dual")
            result = await cursor.fetchone()
            request.logger.info(result[0])
            if result:
                return {"a_column": result[0]}
        return {"a_column": "dunno"}


oracledb = OracleDatabasePlugin(
    config=AsyncDatabaseConfig(
        pool_config=AsyncPoolConfig(user="system", password="super-secret", dsn="localhost:1513/FREEPDB1")  # noqa: S106
    )
)
app = Litestar(plugins=[oracledb], 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_oracledb-0.2.0.tar.gz (70.4 kB view details)

Uploaded Source

Built Distribution

litestar_oracledb-0.2.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litestar_oracledb-0.2.0.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for litestar_oracledb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 44323e8715e45d244342ca5e68cb8c0f9e1a50d142b8dc9a2a453038c8371e89
MD5 cc927360d5fdd99d2cfdb810ef8bcefb
BLAKE2b-256 3bb4b3818ecaab4dd7ca33d99d94962b92930d2c43e2c9ac0b7584909145df64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for litestar_oracledb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8de5c5cba016b609b792b7c161e6f829f9039a7ba87d7a37ca0366750708915
MD5 91ee5a52ea1624412da8f919f0307efa
BLAKE2b-256 c0f9fd1fb1c3440d69d294047308fd3cf8cf5333d46be2f73efd109bddcdd772

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