A non-blocking client for BaseX, implemented on top of python asyncio.
aiobasex
has no dependencies apart from Python standard library.
Currently all the methods of BaseX Command Protocol and Query Command Protocol are implemented, except methods FULL
, INFO
and OPTIONS
of the latter.
from aiobasex import create_connection, BaseXSession
async def example():
"""Connects to BaseX and performs simple query."""
# Instatiate connection, and initialize session with it.
connection = await create_connection(host, port, username=username, password=password)
session = BaseXSession(connection)
# Register XQuery.
query = await session.query('''
declare variable $toCompute as xs:integer external;
declare function local:factorial($N as xs:integer?) as xs:integer {
if ($N <= 1) then
1
else
$N * local:factorial($N - 1)
};
local:factorial($toCompute)
''')
# Bind an external variable.
await query.bind('toCompute', 8)
# Execute query -> prints 40320
print(await query.execute())
# Un-register query at server.
await query.close()
# Close connection.
await connection.close()
Invoke
make test
to run the test suite. Docker and Docker Compose must be installed in order to do this.
- connection pooling
- implement API for
FULL
,INFO
andOPTIONS
- rtfd entry
- 100% test coverage, incl. negative everywhere