@@ -526,6 +526,7 @@ async def connect(dsn=None, *,
526
526
timeout = 60 ,
527
527
statement_cache_size = 100 ,
528
528
command_timeout = None ,
529
+ connection_class = Connection ,
529
530
** opts ):
530
531
"""A coroutine to establish a connection to a PostgreSQL server.
531
532
@@ -558,12 +559,16 @@ async def connect(dsn=None, *,
558
559
559
560
:param float timeout: connection timeout in seconds.
560
561
562
+ :param int statement_cache_size: the size of prepared statement LRU cache.
563
+
561
564
:param float command_timeout: the default timeout for operations on
562
565
this connection (the default is no timeout).
563
566
564
- :param int statement_cache_size: the size of prepared statement LRU cache.
567
+ :param builtins.type connection_class: A class used to represent
568
+ the connection.
569
+ Defaults to :class:`~asyncpg.connection.Connection`.
565
570
566
- :return: A :class:`~asyncpg.connection.Connection` instance.
571
+ :return: A *connection_class* instance.
567
572
568
573
Example:
569
574
@@ -577,6 +582,10 @@ async def connect(dsn=None, *,
577
582
... print(types)
578
583
>>> asyncio.get_event_loop().run_until_complete(run())
579
584
[<Record typname='bool' typnamespace=11 ...
585
+
586
+
587
+ .. versionadded:: 0.10.0
588
+ *connection_class* argument.
580
589
"""
581
590
if loop is None :
582
591
loop = asyncio .get_event_loop ()
@@ -620,9 +629,9 @@ async def connect(dsn=None, *,
620
629
tr .close ()
621
630
raise
622
631
623
- con = Connection (pr , tr , loop , addr , opts ,
624
- statement_cache_size = statement_cache_size ,
625
- command_timeout = command_timeout )
632
+ con = connection_class (pr , tr , loop , addr , opts ,
633
+ statement_cache_size = statement_cache_size ,
634
+ command_timeout = command_timeout )
626
635
pr .set_connection (con )
627
636
return con
628
637
0 commit comments