Skip to content

Commit e2172c3

Browse files
committed
docs: cleanup example
1 parent 6b38593 commit e2172c3

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!-- markdownlint-disable -->
22
<p align="center">
33
<!-- github-banner-start -->
4-
<img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/Branding%20-%20SVG%20-%20Transparent/asyncPG%20-%20Banner%20-%20Inline%20-%20Light.svg#gh-light-mode-only" alt="Litestar Logo - Light" width="100%" height="auto" />
5-
<img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/Branding%20-%20SVG%20-%20Transparent/asyncPG%20-%20Banner%20-%20Inline%20-%20Dark.svg#gh-dark-mode-only" alt="Litestar Logo - Dark" width="100%" height="auto" />
4+
<img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/Branding%20-%20SVG%20-%20Transparent/oracledb%20-%20Banner%20-%20Inline%20-%20Light.svg#gh-light-mode-only" alt="Litestar Logo - Light" width="100%" height="auto" />
5+
<img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/Branding%20-%20SVG%20-%20Transparent/oracledb%20-%20Banner%20-%20Inline%20-%20Dark.svg#gh-dark-mode-only" alt="Litestar Logo - Dark" width="100%" height="auto" />
66
<!-- github-banner-end -->
77
</p>
88
<!-- markdownlint-restore -->
@@ -15,7 +15,7 @@
1515
| --------- | :-- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1616
| 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) |
1717
| 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) |
18-
| 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) ![Advanced Alchemy PyPI - Downloads](https://img.shields.io/pypi/dm/litestar-oracledb?logo=python&label=package%20downloads&labelColor=202235&color=edb641&logoColor=edb641) |
18+
| 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) |
1919
| 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) |
2020
| 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) |
2121

@@ -52,11 +52,15 @@ class SampleController(Controller):
5252
@get(path="/sample")
5353
async def sample_route(self, db_connection: Connection) -> dict[str, str]:
5454
"""Check database available and returns app config info."""
55-
result = await db_connection.fetch("select 1")
55+
cursor = db_connection.cursor()
56+
await cursor.execute("select 1 from dual")
57+
result = await cursor.fetchone()
5658
return {"select_1": str(result)}
5759

5860

59-
oracledb = AsyncpgPlugin(config=AsyncpgConfig(pool_config=PoolConfig(dsn="postgresql://app:app@localhost:5432/app")))
61+
oracledb = OracleDatabasePlugin(
62+
config=AsyncDatabaseConfig(pool_config=AsyncPoolConfig(user="app", password="super-secret", dsn="localhost:1521/freepdb1"))
63+
)
6064
app = Litestar(plugins=[oracledb], route_handlers=[SampleController])
6165

6266
```

examples/basic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@ async def sample_route(self, db_connection: AsyncConnection) -> HealthCheck:
2929

3030

3131
oracledb = OracleDatabasePlugin(
32-
config=AsyncDatabaseConfig(pool_config=AsyncPoolConfig(dsn="app:super-secret@localhost:1521/freepdb1"))
33-
)
32+
config=AsyncDatabaseConfig(pool_config=AsyncPoolConfig(user="app", password="super-secret", dsn="localhost:1521/freepdb1"))) # noqa: S106
3433
app = Litestar(plugins=[oracledb], route_handlers=[SampleController])

tests/conftest.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ def anyio_backend() -> str:
3636

3737

3838
@pytest.fixture(name="async_connection_pool", scope="session")
39-
async def async_connection_pool(
39+
def async_connection_pool(
4040
oracle_docker_ip: str,
4141
oracle_user: str,
4242
oracle_password: str,
4343
oracle_service_name: str,
4444
oracle_port: int,
4545
oracle_service: None,
46-
) -> AsyncGenerator[AsyncConnectionPool, None]:
46+
) -> Generator[AsyncConnectionPool, None, None]:
4747
"""App fixture.
4848
4949
Returns:
@@ -82,27 +82,27 @@ def sync_connection_pool(
8282

8383

8484
@pytest.fixture(name="sync_plugin")
85-
async def sync_config(sync_connection_pool: ConnectionPool) -> SyncDatabaseConfig:
85+
def sync_config(sync_connection_pool: ConnectionPool) -> Generator[SyncDatabaseConfig,None,None]:
8686
"""App fixture.
8787
8888
Returns:
8989
An application instance, configured via plugin.
9090
"""
9191

92-
return SyncDatabaseConfig(
92+
yield SyncDatabaseConfig(
9393
pool_instance=sync_connection_pool,
9494
)
9595

9696

9797
@pytest.fixture(name="async_config")
98-
async def async_config(async_connection_pool: AsyncConnectionPool) -> AsyncDatabaseConfig:
98+
def async_config(async_connection_pool: AsyncConnectionPool) -> Generator[AsyncDatabaseConfig,None,None]:
9999
"""App fixture.
100100
101101
Returns:
102102
An application instance, configured via plugin.
103103
"""
104104

105-
return AsyncDatabaseConfig(
105+
yield AsyncDatabaseConfig(
106106
pool_instance=async_connection_pool,
107107
)
108108

@@ -131,10 +131,10 @@ async def plugin(request: FixtureRequest) -> AsyncGenerator[OracleDatabasePlugin
131131

132132

133133
@pytest.fixture(name="app")
134-
def fx_app(plugin: OracleDatabasePlugin) -> Litestar:
134+
def fx_app(plugin: OracleDatabasePlugin) -> Generator[Litestar,None, None]:
135135
"""App fixture.
136136
137137
Returns:
138138
An application instance, configured via plugin.
139139
"""
140-
return Litestar(plugins=[plugin], route_handlers=[SampleController])
140+
yield Litestar(plugins=[plugin], route_handlers=[SampleController])

0 commit comments

Comments
 (0)