Low-level (older) API
Note: all query methods are coroutines.
Select, update, delete
- async peewee_async.execute(query)
- async peewee_async.prefetch(sq, *subqueries, prefetch_type)
Asynchronous version of the prefetch() from peewee.
Transactions
Transactions required Python 3.5+ to work, because their syntax is based on async context managers.
Important note transactions rely on data isolation on asyncio per-task basis. That means, all queries for single transaction should be performed within same task.
- peewee_async.atomic(db)
Asynchronous context manager (async with), similar to peewee.atomic().
- peewee_async.savepoint(db, sid=None)
- peewee_async.transaction(db)
Asynchronous context manager (async with), similar to peewee.transaction(). Will start new asyncio task for transaction if not started already.
Aggregation
- async peewee_async.count(query, clear_limit=False)
Perform COUNT aggregated query asynchronously.
- Returns:
number of objects in select() query
- async peewee_async.scalar(query, as_tuple=False)
Databases
- class peewee_async.PostgresqlDatabase(database, **kwargs)
PosgreSQL database driver providing single drop-in sync connection and single async connection interface.
Example:
database = PostgresqlDatabase('test')
See also: http://peewee.readthedocs.io/en/latest/peewee/api.html#PostgresqlDatabase
- atomic_async()
Similar to peewee Database.atomic() method, but returns asynchronous context manager.
- savepoint_async(sid=None)
Similar to peewee Database.savepoint() method, but returns asynchronous context manager.
- transaction_async()
Similar to peewee Database.transaction() method, but returns asynchronous context manager.
- class peewee_async.PooledPostgresqlDatabase(database, **kwargs)
PosgreSQL database driver providing single drop-in sync connection and async connections pool interface.
- Parameters:
max_connections – connections pool size
Example:
database = PooledPostgresqlDatabase('test', max_connections=20)
See also: http://peewee.readthedocs.io/en/latest/peewee/api.html#PostgresqlDatabase
- class peewee_asyncext.PostgresqlExtDatabase(database, **kwargs)
PosgreSQL database extended driver providing single drop-in sync connection and single async connection interface.
JSON fields support is always enabled, HStore supports is enabled by default, but can be disabled with
register_hstore=False
argument.Example:
database = PostgresqlExtDatabase('test', register_hstore=False)
See also: https://peewee.readthedocs.io/en/latest/peewee/playhouse.html#PostgresqlExtDatabase
- atomic_async()
Similar to peewee Database.atomic() method, but returns asynchronous context manager.
- savepoint_async(sid=None)
Similar to peewee Database.savepoint() method, but returns asynchronous context manager.
- transaction_async()
Similar to peewee Database.transaction() method, but returns asynchronous context manager.
- class peewee_asyncext.PooledPostgresqlExtDatabase(database, **kwargs)
PosgreSQL database extended driver providing single drop-in sync connection and async connections pool interface.
JSON fields support is always enabled, HStore supports is enabled by default, but can be disabled with
register_hstore=False
argument.- Parameters:
max_connections – connections pool size
Example:
database = PooledPostgresqlExtDatabase('test', register_hstore=False, max_connections=20)
See also: https://peewee.readthedocs.io/en/latest/peewee/playhouse.html#PostgresqlExtDatabase