File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export default sidebar({
6565 "litestar" ,
6666 "blacksheep" ,
6767 "robyn" ,
68+ "panther" ,
6869 ]
6970 } ,
7071 ] ,
Original file line number Diff line number Diff line change 1+ ---
2+ title : Panther
3+ ---
4+
5+ There is the default example for ` Panther ` framework.
6+
7+ We strongly recommend to use the following example as a standard way to use ` PSQLPy ` with ` Panther ` framework.
8+
9+ ## Complete example
10+
11+ ``` python
12+ import uvicorn
13+ from psqlpy import ConnectionPool
14+
15+ from panther import Panther
16+ from panther.app import API
17+ from panther.configs import config
18+ from panther.events import Event
19+ from panther.response import Response
20+
21+
22+ @Event.startup
23+ async def create_connection_pool ():
24+ config.connection_pool = ConnectionPool(
25+ dsn = " postgres://postgres:postgres@localhost:5432/postgres" ,
26+ max_db_pool_size = 10 ,
27+ )
28+
29+
30+ @Event.shutdown
31+ async def close_connection_pool ():
32+ config.connection_pool.close()
33+
34+
35+ @API ()
36+ async def pg_pool_example ():
37+ connection = await config.connection_pool.connection()
38+ query_result = await connection.execute(
39+ " SELECT * FROM users" ,
40+ )
41+ return Response(data = query_result.result())
42+
43+
44+ app = Panther(__name__ , configs = __name__ , urls = {' /' : pg_pool_example})
45+
46+ if __name__ == " __main__" :
47+ uvicorn.run(app)
48+ ```
You can’t perform that action at this time.
0 commit comments