Package: aiopg
aiopgis a library for accessing aPostgreSQLdatabase
from theasyncio(PEP-3156/tulip) framework. It wraps
asynchronous features of the Psycopg database driver.Exampleimportasyncioimportaiopgdsn='dbname=aiopg user=aiopg password=passwd host=127.0.0.1'asyncdefgo():pool=awaitaiopg.create_pool(dsn)asyncwithpool.acquire()asconn:asyncwithconn.cursor()ascur:awaitcur.execute("SELECT 1")ret=[]asyncforrowincur:ret.append(row)assertret==[(1,)]loop=asyncio.get_event_loop()loop.run_until_complete(go())Example of SQLAlchemy optional integrationimportasynciofromaiopg.saimportcreate_engineimportsqlalchemyassametadata=sa.MetaData()tbl=sa.Table('tbl',metadata,sa.Column('id',sa.Integer,primary_key=True),sa.Column('val',sa.String(255)))asyncdefcreate_table(engine):asyncwithengine.acquire()asconn:awaitconn.execute('DROP TABLE IF EXISTS tbl')awaitconn.execute('''CREATE TABLE tbl (
                                  id serial PRIMARY KEY,
                                  val varchar(255))''')asyncdefgo():asyncwithcreate_engine(user='aiopg',database='aiopg',host='127.0.0.1',password='passwd')asengine:asyncwithengine.acquire()asconn:awaitconn.execute(tbl.insert().values(val='abc'))asyncforrowinconn.execute(tbl.select()):print(row.id,row.val)loop=asyncio.get_event_loop()loop.run_until_complete(go())Please use:$ make testfor executing the project’s unittests.
Seehttps://aiopg.readthedocs.io/en/stable/contributing.htmlfor details
on how to set up your environment to run the tests.Changelog1.4.0 (2022-10-26)Add python 3.11 and drop python 3.6 support` #892 <https://github.com/aio-libs/aiopg/pull/892>`_1.3.5 (2022-09-25)Fix pool size limit check for unlimited pools#8881.3.4 (2022-06-30)1.3.4b3 (2022-06-29)1.3.4b2 (2022-06-29)1.3.4b1 (2022-06-29)Fix compatibility with SA 1.4.38#891Add py.typed marker#8781.3.3 (2021-11-01)Support async-timeout 4.0+1.3.2 (2021-10-07)1.3.2b2 (2021-10-07)Respect use_labels for select statement#8821.3.2b1 (2021-07-11)Fix compatibility with SQLAlchemy >= 1.4#8701.3.1 (2021-07-08)1.3.1b2 (2021-07-06)Suppress “Future exception was never retrieved”#8621.3.1b1 (2021-07-05)Fix ClosableQueue.get on cancellation, close it on Connection.close#8591.3.0 (2021-06-30)1.3.0b4 (2021-06-28)Fix “Unable to detect disconnect when using NOTIFY/LISTEN”#5591.3.0b3 (2021-04-03)Reformat using black#8141.3.0b2 (2021-04-02)Type annotations#8131.3.0b1 (2021-03-30)Raise ResourceClosedError if we try to open a cursor on a closed SAConnection#8111.3.0b0 (2021-03-25)Fix compatibility with SA 1.4 for IN statement#8061.2.1 (2021-03-23)Pop loop in connection init due to backward compatibility#8081.2.0b4 (2021-03-23)Set max supported sqlalchemy version#8051.2.0b3 (2021-03-22)Don’t run ROLLBACK when the connection is closed#778Multiple cursors support#8011.2.0b2 (2020-12-21)Fix IsolationLevel.read_committed and introduce IsolationLevel.default#770Fix python 3.8 warnings in tests#7711.2.0b1 (2020-12-16)Deprecate blocking connection.cancel() method#5701.2.0b0 (2020-12-15)Implement timeout on acquiring connection from pool#7661.1.0 (2020-12-10)1.1.0b2 (2020-12-09)Added missing slots to context managers#7631.1.0b1 (2020-12-07)Fix on_connect multiple call on acquire#552Fix python 3.8 warnings#622Bump minimum psycopg version to 2.8.4#754Fix Engine.release method to release connection in any way#7561.0.0 (2019-09-20)Removal of an asynchronous call in favor of issues # 550Big editing of documentation and minor bugs #5340.16.0 (2019-01-25)Fix select priority name#525Renamepsycopg2topsycopg2-binaryto fix deprecation warning#507Fix#189hstore when using ReadDictCursor#512close cannot be used while an asynchronous query is underway#452sqlalchemy adapter trx begin allow transaction_mode#4980.15.0 (2018-08-14)Support Python 3.7#4370.14.0 (2018-05-10)Addget_dialectfunc to have ability to passjson_serializer#4510.13.2 (2018-01-03)Fixed compatibility with SQLAlchemy 1.2.0#412Added support for transaction isolation levels#2190.13.1 (2017-09-10)Added connection poll recycling logic#3730.13.0 (2016-12-02)Addasync withsupport to.begin_nested()#208Fix connection.cancel()#212#223Raise informative error on unexpected connection closing#191Added support for python types columns issues#217Added support for default values in SA table issues#2060.12.0 (2016-10-09)Add an on_connect callback parameter to pool#141Fixed connection to work under both windows and posix based systems#1420.11.0 (2016-09-12)Immediately remove callbacks from a closed file descriptor#139Drop Python 3.3 support0.10.0 (2016-07-16)Refactor tests to use dockerized Postgres server#107Reduce default pool minsize to 1#106Explicitly enumerate packages in setup.py#85Remove expired connections from pool on acquire#116Don’t crash when Connection is GC’ed#124Use loop.create_future() if available0.9.2 (2016-01-31)Make pool.release return asyncio.Future, so we can wait on it in__aexit__#102Add support for uuid type#1030.9.1 (2016-01-17)Documentation update#1010.9.0 (2016-01-14)Add async context managers for transactions#91Support async iterator in ResultProxy#92Add async with for engine#900.8.0 (2015-12-31)Add PostgreSQL notification support#58Support pools with unlimited size#59Cancel current DB operation on asyncio timeout#66Add async with support for Pool, Connection, Cursor#880.7.0 (2015-04-22)Get rid of resource leak on connection failure.Report ResourceWarning on non-closed connections.Deprecate iteration protocol support in cursor and ResultProxy.Release sa connection to pool onconnection.close().0.6.0 (2015-02-03)Accept dict, list, tuple, named and positional parameters inSAConnection.execute()0.5.2 (2014-12-08)Minor release, fixes a bug that leaves connection in broken state
aftercursor.execute()failure.0.5.1 (2014-10-31)Fix a bug for processing transactions in line.0.5.0 (2014-10-31)Add .terminate() to Pool and EngineReimplement connection pool (now pool size cannot be greater than pool.maxsize)Add .close() and .wait_closed() to Pool and EngineAdd minsize, maxsize, size and freesize properties to sa.EngineSupportechoparameter for logging executed SQL commandsConnection.close() is not a coroutine (but we keep backward compatibility).0.4.1 (2014-10-02)make cursor iterableupdate docs0.4.0 (2014-10-02)add timeouts for database operations.Autoregister psycopg2 support for json data type.Support JSON in aiopg.saSupport ARRAY in aiopg.saAutoregister hstore support if present in connected DBSupport HSTORE in aiopg.sa0.3.2 (2014-07-07)change signature to cursor.execute(operation, parameters=None) to
follow psycopg2 convention.0.3.1 (2014-07-04)Forward arguments to cursor constructor for pooled connections.0.3.0 (2014-06-22)Allow executing SQLAlchemy DDL statements.Fix bug with race conditions on acquiring/releasing connections from pool.0.2.3 (2014-06-12)Fix bug in connection pool.0.2.2 (2014-06-07)Fix bug with passing parameters into SAConnection.execute when
executing raw SQL expression.0.2.1 (2014-05-08)Close connection with invalid transaction status on returning to pool.0.2.0 (2014-05-04)Implemented optional support for sqlalchemy functional sql layer.0.1.0 (2014-04-06)Implemented plain connections: connect, Connection, Cursor.Implemented database pools: create_pool and Pool.