Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/litestar-org/litestar-oracledb

An Oracle Database plugin for Litestar
https://github.com/litestar-org/litestar-oracledb

litestar litestar-org litestar-plugin oracle oracle-database oracle-db oracle-integration

Last synced: 6 days ago
JSON representation

An Oracle Database plugin for Litestar

Awesome Lists containing this project

README

        



Litestar Logo - Light
Litestar Logo - Dark

| Project | | Status |
| --------- | :-- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| CI/CD | | [![Latest Release](https://github.com/litestar-org/litestar-oracledb/actions/workflows/publish.yml/badge.svg)](https://github.com/litestar-org/litestar-oracledb/actions/workflows/publish.yml) [![ci](https://github.com/litestar-org/litestar-oracledb/actions/workflows/ci.yml/badge.svg)](https://github.com/litestar-org/litestar-oracledb/actions/workflows/ci.yml) [![Documentation Building](https://github.com/litestar-org/litestar-oracledb/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/litestar-org/litestar-oracledb/actions/workflows/docs.yml) |
| Quality | | [![Coverage](https://codecov.io/github/litestar-org/litestar-oracledb/graph/badge.svg?token=vKez4Pycrc)](https://codecov.io/github/litestar-org/litestar-oracledb) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-oracledb&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-oracledb) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-oracledb&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-oracledb) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-oracledb&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-oracledb) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar-oracledb&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-oracledb) |
| Package | | [![PyPI - Version](https://img.shields.io/pypi/v/litestar-oracledb?labelColor=202235&color=edb641&logo=python&logoColor=edb641)](https://badge.fury.io/py/litestar) ![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/litestar?labelColor=202235&color=edb641&logo=python&logoColor=edb641) ![Litestar OracleDB PyPI - Downloads](https://img.shields.io/pypi/dm/litestar-oracledb?logo=python&label=package%20downloads&labelColor=202235&color=edb641&logoColor=edb641) |
| Community | | [![Reddit](https://img.shields.io/reddit/subreddit-subscribers/litestarapi?label=r%2FLitestar&logo=reddit&labelColor=202235&color=edb641&logoColor=edb641)](https://reddit.com/r/litestarapi) [![Discord](https://img.shields.io/discord/919193495116337154?labelColor=202235&color=edb641&label=chat%20on%20discord&logo=discord&logoColor=edb641)](https://discord.gg/litestar) [![Matrix](https://img.shields.io/badge/chat%20on%20Matrix-bridged-202235?labelColor=202235&color=edb641&logo=matrix&logoColor=edb641)](https://matrix.to/#/#litestar:matrix.org) [![Medium](https://img.shields.io/badge/Medium-202235?labelColor=202235&color=edb641&logo=medium&logoColor=edb641)](https://blog.litestar.dev) [![Twitter](https://img.shields.io/twitter/follow/LitestarAPI?labelColor=202235&color=edb641&logo=twitter&logoColor=edb641&style=flat)](https://twitter.com/LitestarAPI) [![Blog](https://img.shields.io/badge/Blog-litestar.dev-202235?logo=blogger&labelColor=202235&color=edb641&logoColor=edb641)](https://blog.litestar.dev) |
| Meta | | [![Litestar Project](https://img.shields.io/badge/Litestar%20Org-%E2%AD%90%20Advanced%20Alchemy-202235.svg?logo=python&labelColor=202235&color=edb641&logoColor=edb641)](https://github.com/litestar-org/litestar-oracledb) [![types - Mypy](https://img.shields.io/badge/types-Mypy-202235.svg?logo=python&labelColor=202235&color=edb641&logoColor=edb641)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-202235.svg?logo=python&labelColor=202235&color=edb641&logoColor=edb641)](https://spdx.org/licenses/) [![Litestar Sponsors](https://img.shields.io/badge/Sponsor-%E2%9D%A4-%23edb641.svg?&logo=github&logoColor=edb641&labelColor=202235)](https://github.com/sponsors/litestar-org) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json&labelColor=202235)](https://github.com/astral-sh/ruff) [![code style - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json&labelColor=202235)](https://github.com/psf/black) |


# 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

```shell
pip install litestar-oracledb
```

### Example

Here is a basic application that demonstrates how to use the plugin.

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

```