Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vuepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default sidebar({
"litestar",
"blacksheep",
"robyn",
"panther",
]
},
],
Expand Down
48 changes: 48 additions & 0 deletions docs/usage/frameworks/panther.md
Original file line number Diff line number Diff line change
@@ -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)
```
Loading