Postgress integration with asyncio.
Project description
aiopg is a library for accessing a PostgreSQL database from the asyncio (PEP-3156/tulip) framework. It wraps asynchronous features of the Psycopg database driver.
Example
import asyncio from aiopg.pool import create_pool dsn = 'dbname=jetty user=nick password=1234 host=localhost port=5432' @asyncio.coroutine def test_select(): pool = yield from create_pool(dsn) with (yield from pool) as conn: cur = yield from conn.cursor() yield from cur.execute('SELECT 1') ret = yield from cur.fetchone() assert ret == (1,), ret asyncio.get_event_loop().run_until_complete(test_select())
Example of SQLAlchemy optional integration
import asyncio from aiopg.sa import create_engine import sqlalchemy as sa metadata = sa.MetaData() tbl = sa.Table('tbl', metadata, sa.Column('id', sa.Integer, primary_key=True), sa.Column('val', sa.String(255))) @asyncio.coroutine def go(): engine = yield from create_engine(user='aiopg', database='aiopg', host='127.0.0.1', password='passwd') with (yield from engine) as conn: yield from conn.execute(tbl.insert().values(val='abc')) res = yield from conn.execute(tbl.select()) for row in res: print(row.id, row.val) asyncio.get_event_loop().run_until_complete(go())
CHANGES
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiopg-0.2.1.tar.gz
(16.4 kB
view details)
Built Distribution
aiopg-0.2.1-py3-none-any.whl
(30.9 kB
view details)
File details
Details for the file aiopg-0.2.1.tar.gz
.
File metadata
- Download URL: aiopg-0.2.1.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 504f7ec72b58ae2ca134ababcf45cac060802a883a84edef426a04abed2daebd |
|
MD5 | 79a768f09df5015f31fc7cb6215a545b |
|
BLAKE2b-256 | 7c086d6c43348d2dbbbb6224dec83ba7ff390da881217e4d35abadc48b583df5 |
File details
Details for the file aiopg-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: aiopg-0.2.1-py3-none-any.whl
- Upload date:
- Size: 30.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a62f4b0fb2734bb748d7b87bc4214def69e10ca93d2a4c9bab97cee9fe5af8e3 |
|
MD5 | 570c7dcb5555a9968644ae02f4313e53 |
|
BLAKE2b-256 | 790a8647f48c8fce0bea9d430c33695baf63ddd8ff41d564240bc0098088229b |