Skip to content

Commit

Permalink
Merge branch 'master' into trashcan
Browse files Browse the repository at this point in the history
  • Loading branch information
elprans authored Jul 17, 2024
2 parents 2f7cbbb + 7f00484 commit 0d34cba
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ jobs:
version_line_pattern: |
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
- name: Setup PostgreSQL
uses: tj-actions/install-postgresql@2a80e9368dff47cd05fee5bf3cf7d88f68c2f8e9 # v3.1.1
if: steps.release.outputs.version == 0 && matrix.os == 'macos-latest'
with:
postgresql-version: 16

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
if: steps.release.outputs.version == 0
Expand Down
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ Basic Usage
)
await conn.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
asyncio.run(run())
License
Expand Down
26 changes: 12 additions & 14 deletions asyncpg/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ def add_query_logger(self, callback):
:param callable callback:
A callable or a coroutine function receiving one argument:
**record**: a LoggedQuery containing `query`, `args`, `timeout`,
`elapsed`, `exception`, `conn_addr`, and
`conn_params`.
**record**, a LoggedQuery containing `query`, `args`, `timeout`,
`elapsed`, `exception`, `conn_addr`, and `conn_params`.
.. versionadded:: 0.29.0
"""
Expand Down Expand Up @@ -800,7 +799,7 @@ async def copy_from_table(self, table_name, *, output,
... output='file.csv', format='csv')
... print(result)
...
>>> asyncio.get_event_loop().run_until_complete(run())
>>> asyncio.run(run())
'COPY 100'
.. _`COPY statement documentation`:
Expand Down Expand Up @@ -869,7 +868,7 @@ async def copy_from_query(self, query, *args, output,
... output='file.csv', format='csv')
... print(result)
...
>>> asyncio.get_event_loop().run_until_complete(run())
>>> asyncio.run(run())
'COPY 10'
.. _`COPY statement documentation`:
Expand Down Expand Up @@ -945,7 +944,7 @@ async def copy_to_table(self, table_name, *, source,
... 'mytable', source='datafile.tbl')
... print(result)
...
>>> asyncio.get_event_loop().run_until_complete(run())
>>> asyncio.run(run())
'COPY 140000'
.. _`COPY statement documentation`:
Expand Down Expand Up @@ -1027,7 +1026,7 @@ async def copy_records_to_table(self, table_name, *, records,
... (2, 'ham', 'spam')])
... print(result)
...
>>> asyncio.get_event_loop().run_until_complete(run())
>>> asyncio.run(run())
'COPY 2'
Asynchronous record iterables are also supported:
Expand All @@ -1045,7 +1044,7 @@ async def copy_records_to_table(self, table_name, *, records,
... 'mytable', records=record_gen(100))
... print(result)
...
>>> asyncio.get_event_loop().run_until_complete(run())
>>> asyncio.run(run())
'COPY 100'
.. versionadded:: 0.11.0
Expand Down Expand Up @@ -1305,7 +1304,7 @@ async def set_type_codec(self, typename, *,
... print(result)
... print(datetime.datetime(2002, 1, 1) + result)
...
>>> asyncio.get_event_loop().run_until_complete(run())
>>> asyncio.run(run())
relativedelta(years=+2, months=+3, days=+1)
2004-04-02 00:00:00
Expand Down Expand Up @@ -1772,7 +1771,7 @@ async def reload_schema_state(self):
... await con.execute('LOCK TABLE tbl')
... await change_type(con)
...
>>> asyncio.get_event_loop().run_until_complete(run())
>>> asyncio.run(run())
.. versionadded:: 0.14.0
"""
Expand Down Expand Up @@ -1809,9 +1808,8 @@ def query_logger(self, callback):
:param callable callback:
A callable or a coroutine function receiving one argument:
**record**: a LoggedQuery containing `query`, `args`, `timeout`,
`elapsed`, `exception`, `conn_addr`, and
`conn_params`.
**record**, a LoggedQuery containing `query`, `args`, `timeout`,
`elapsed`, `exception`, `conn_addr`, and `conn_params`.
Example:
Expand Down Expand Up @@ -2258,7 +2256,7 @@ async def connect(dsn=None, *,
... types = await con.fetch('SELECT * FROM pg_type')
... print(types)
...
>>> asyncio.get_event_loop().run_until_complete(run())
>>> asyncio.run(run())
[<Record typname='bool' typnamespace=11 ...
.. versionadded:: 0.10.0
Expand Down
3 changes: 1 addition & 2 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ a need to run the same query again.
.. code-block:: pycon
>>> import asyncpg, asyncio
>>> loop = asyncio.get_event_loop()
>>> async def run():
... conn = await asyncpg.connect()
... stmt = await conn.prepare('''SELECT 2 ^ $1''')
... print(await stmt.fetchval(10))
... print(await stmt.fetchval(20))
...
>>> loop.run_until_complete(run())
>>> asyncio.run(run())
1024.0
1048576.0
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

with open(version_file, 'r') as f:
for line in f:
if line.startswith('__version__ ='):
if line.startswith('__version__: typing.Final ='):
_, _, version = line.partition('=')
version = version.strip(" \n'\"")
break
Expand Down
7 changes: 3 additions & 4 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ which provides methods to run queries and manage transactions.
# Close the connection.
await conn.close()
asyncio.get_event_loop().run_until_complete(main())
asyncio.run(main())
.. note::
Expand Down Expand Up @@ -344,7 +343,7 @@ shows how to instruct asyncpg to use floats instead.
finally:
await conn.close()
asyncio.get_event_loop().run_until_complete(main())
asyncio.run(main())
Example: decoding hstore values
Expand All @@ -369,7 +368,7 @@ be registered on a connection using :meth:`Connection.set_builtin_type_codec()
result = await conn.fetchval("SELECT 'a=>1,b=>2,c=>NULL'::hstore")
assert result == {'a': '1', 'b': '2', 'c': None}
asyncio.get_event_loop().run_until_complete(run())
asyncio.run(run())
.. _hstore: https://www.postgresql.org/docs/current/static/hstore.html

Expand Down
5 changes: 1 addition & 4 deletions tools/generate_type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ def main():
help='PostgreSQL server user')

args = parser.parse_args()

loop = asyncio.get_event_loop()

loop.run_until_complete(runner(args))
asyncio.run(runner(args))


if __name__ == '__main__':
Expand Down

0 comments on commit 0d34cba

Please sign in to comment.