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: 14 days ago
JSON representation
An Oracle Database plugin for Litestar
- Host: GitHub
- URL: https://github.com/litestar-org/litestar-oracledb
- Owner: litestar-org
- License: mit
- Created: 2024-08-29T18:19:55.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-28T05:29:57.000Z (about 2 months ago)
- Last Synced: 2025-04-02T18:57:39.350Z (22 days ago)
- Topics: litestar, litestar-org, litestar-plugin, oracle, oracle-database, oracle-db, oracle-integration
- Language: Python
- Homepage:
- Size: 110 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.rst
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
![]()
![]()
| Project | | Status |
| --------- | :-- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| CI/CD | | [](https://github.com/litestar-org/litestar-oracledb/actions/workflows/publish.yml) [](https://github.com/litestar-org/litestar-oracledb/actions/workflows/ci.yml) [](https://github.com/litestar-org/litestar-oracledb/actions/workflows/docs.yml) |
| Quality | | [](https://codecov.io/github/litestar-org/litestar-oracledb) [](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-oracledb) [](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-oracledb) [](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-oracledb) [](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar-oracledb) |
| Package | | [](https://badge.fury.io/py/litestar)   |
| Community | | [](https://reddit.com/r/litestarapi) [](https://discord.gg/litestar) [](https://matrix.to/#/#litestar:matrix.org) [](https://blog.litestar.dev) [](https://twitter.com/LitestarAPI) [](https://blog.litestar.dev) |
| Meta | | [](https://github.com/litestar-org/litestar-oracledb) [](https://github.com/python/mypy) [](https://spdx.org/licenses/) [](https://github.com/sponsors/litestar-org) [](https://github.com/astral-sh/ruff) [](https://github.com/psf/black) |
# Litestar - Oracle Database PluginA 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 annotationsfrom typing import TYPE_CHECKING
from litestar import Controller, Litestar, Request, get
from litestar_oracledb import AsyncDatabaseConfig, AsyncPoolConfig, OracleDatabasePlugin
if TYPE_CHECKING:
from oracledb import AsyncConnectionclass 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])```