r"""Create a connection pool. Can be used either with an ``async with`` block: .. code-block:: python async with asyncpg.create_pool(user='postgres', command_timeout=60) as pool: await pool.fetch('SELECT 1') Or to perform mul
(dsn=None, *,
min_size=10,
max_size=10,
max_queries=50000,
max_inactive_connection_lifetime=300.0,
connect=None,
setup=None,
init=None,
reset=None,
loop=None,
connection_class=connection.Connection,
record_class=protocol.Record,
**connect_kwargs)
| 1073 | |
| 1074 | |
| 1075 | def create_pool(dsn=None, *, |
| 1076 | min_size=10, |
| 1077 | max_size=10, |
| 1078 | max_queries=50000, |
| 1079 | max_inactive_connection_lifetime=300.0, |
| 1080 | connect=None, |
| 1081 | setup=None, |
| 1082 | init=None, |
| 1083 | reset=None, |
| 1084 | loop=None, |
| 1085 | connection_class=connection.Connection, |
| 1086 | record_class=protocol.Record, |
| 1087 | **connect_kwargs): |
| 1088 | r"""Create a connection pool. |
| 1089 | |
| 1090 | Can be used either with an ``async with`` block: |
| 1091 | |
| 1092 | .. code-block:: python |
| 1093 | |
| 1094 | async with asyncpg.create_pool(user='postgres', |
| 1095 | command_timeout=60) as pool: |
| 1096 | await pool.fetch('SELECT 1') |
| 1097 | |
| 1098 | Or to perform multiple operations on a single connection: |
| 1099 | |
| 1100 | .. code-block:: python |
| 1101 | |
| 1102 | async with asyncpg.create_pool(user='postgres', |
| 1103 | command_timeout=60) as pool: |
| 1104 | async with pool.acquire() as con: |
| 1105 | await con.execute(''' |
| 1106 | CREATE TABLE names ( |
| 1107 | id serial PRIMARY KEY, |
| 1108 | name VARCHAR (255) NOT NULL) |
| 1109 | ''') |
| 1110 | await con.fetch('SELECT 1') |
| 1111 | |
| 1112 | Or directly with ``await`` (not recommended): |
| 1113 | |
| 1114 | .. code-block:: python |
| 1115 | |
| 1116 | pool = await asyncpg.create_pool(user='postgres', command_timeout=60) |
| 1117 | con = await pool.acquire() |
| 1118 | try: |
| 1119 | await con.fetch('SELECT 1') |
| 1120 | finally: |
| 1121 | await pool.release(con) |
| 1122 | |
| 1123 | .. warning:: |
| 1124 | Prepared statements and cursors returned by |
| 1125 | :meth:`Connection.prepare() <asyncpg.connection.Connection.prepare>` |
| 1126 | and :meth:`Connection.cursor() <asyncpg.connection.Connection.cursor>` |
| 1127 | become invalid once the connection is released. Likewise, all |
| 1128 | notification and log listeners are removed, and ``asyncpg`` will |
| 1129 | issue a warning if there are any listener callbacks registered on a |
| 1130 | connection that is being released to the pool. |
| 1131 | |
| 1132 | :param str dsn: |
nothing calls this directly
no test coverage detected
searching dependent graphs…