Skip to content
/ aiobasex Public

non-blocking client for BaseX, based on python/asyncio platform

License

Notifications You must be signed in to change notification settings

mksh/aiobasex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aiobasex

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.

Usage example

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()

Testing

Invoke

make test

to run the test suite. Docker and Docker Compose must be installed in order to do this.

TODO

  • connection pooling
  • implement API for FULL, INFO and OPTIONS
  • rtfd entry
  • 100% test coverage, incl. negative everywhere

About

non-blocking client for BaseX, based on python/asyncio platform

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published