From e7adf9f6fa6020df4a3a1cfd1f2901a674b4ef68 Mon Sep 17 00:00:00 2001 From: Ali RajabNezhad Date: Sat, 12 Jul 2025 03:09:45 +0330 Subject: [PATCH] Add `Panther` framework usage example --- docs/.vuepress/sidebar.ts | 1 + docs/usage/frameworks/panther.md | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 docs/usage/frameworks/panther.md diff --git a/docs/.vuepress/sidebar.ts b/docs/.vuepress/sidebar.ts index 7a03377d..5684490f 100644 --- a/docs/.vuepress/sidebar.ts +++ b/docs/.vuepress/sidebar.ts @@ -65,6 +65,7 @@ export default sidebar({ "litestar", "blacksheep", "robyn", + "panther", ] }, ], diff --git a/docs/usage/frameworks/panther.md b/docs/usage/frameworks/panther.md new file mode 100644 index 00000000..35d25ced --- /dev/null +++ b/docs/usage/frameworks/panther.md @@ -0,0 +1,48 @@ +--- +title: Panther +--- + +There is the default example for `Panther` framework. + +We strongly recommend to use the following example as a standard way to use `PSQLPy` with `Panther` framework. + +## Complete example + +```python +import uvicorn +from psqlpy import ConnectionPool + +from panther import Panther +from panther.app import API +from panther.configs import config +from panther.events import Event +from panther.response import Response + + +@Event.startup +async def create_connection_pool(): + config.connection_pool = ConnectionPool( + dsn="postgres://postgres:postgres@localhost:5432/postgres", + max_db_pool_size=10, + ) + + +@Event.shutdown +async def close_connection_pool(): + config.connection_pool.close() + + +@API() +async def pg_pool_example(): + connection = await config.connection_pool.connection() + query_result = await connection.execute( + "SELECT * FROM users", + ) + return Response(data=query_result.result()) + + +app = Panther(__name__, configs=__name__, urls={'/': pg_pool_example}) + +if __name__ == "__main__": + uvicorn.run(app) +``` \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy