This repository was archived by the owner on Aug 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,7 +62,14 @@ def _get_connection_kwargs(self) -> dict:
6262 async def connect (self ) -> None :
6363 assert self ._pool is None , "DatabaseBackend is already running"
6464 kwargs = self ._get_connection_kwargs ()
65- self ._pool = await asyncpg .create_pool (str (self ._database_url ), ** kwargs )
65+ self ._pool = await asyncpg .create_pool (
66+ host = self ._database_url .hostname ,
67+ port = self ._database_url .port ,
68+ user = self ._database_url .username ,
69+ password = self ._database_url .password ,
70+ database = self ._database_url .database ,
71+ ** kwargs ,
72+ )
6673
6774 async def disconnect (self ) -> None :
6875 assert self ._pool is not None , "DatabaseBackend is not running"
Original file line number Diff line number Diff line change 55from databases .backends .aiopg import AiopgBackend
66from databases .backends .mysql import MySQLBackend
77from databases .backends .postgres import PostgresBackend
8+ from databases .core import DatabaseURL
9+ from tests .test_databases import DATABASE_URLS , async_adapter
810
911
1012def test_postgres_pool_size ():
@@ -13,6 +15,16 @@ def test_postgres_pool_size():
1315 assert kwargs == {"min_size" : 1 , "max_size" : 20 }
1416
1517
18+ @async_adapter
19+ async def test_postgres_pool_size_connect ():
20+ for url in DATABASE_URLS :
21+ if DatabaseURL (url ).dialect != "postgresql" :
22+ continue
23+ backend = PostgresBackend (url + "?min_size=1&max_size=20" )
24+ await backend .connect ()
25+ await backend .disconnect ()
26+
27+
1628def test_postgres_explicit_pool_size ():
1729 backend = PostgresBackend ("postgres://localhost/database" , min_size = 1 , max_size = 20 )
1830 kwargs = backend ._get_connection_kwargs ()
You can’t perform that action at this time.
0 commit comments