Reference

class Client(url='http://localhost:4000', token=None, query='/query', state='/state', callback=None)

Communicates with the module’s server protocol.

Parameters:
  • url (str) – Server url.
  • token (str) – Authorization token.
  • query (str) – Database query path.
  • state (str) – Websocket connection path.
  • callback (func) –

    Called upon events with:

    Index Type Description
    0 str create, update or delete.
    1 str Table name.
    2 tuple[Entry] Single entries or (old, new) pairs (update only).
Variables:

tables (Entry) – Contains Tables against their names.

Note

Tables without primary keys will be generated, but: - Their cache won’t be filled - Events related to them won’t be dispatched.

start()

Create the session, fetch schema, fill cache, connect to websocket, listen for events.

stop()

Close the session and websocket connections.

class Table

Represents a database table.

Variables:
  • name (str) – The table’s name.
  • fields (Entry) –

    Contains fields against their names with the following details:

    Attribute Type Description
    name str Its name.
    main bool Whether this is a primary key.
    type str PostgreSQL type name.
    dims int Number of array dimensions.
    null bool Whether this is nullable.
    info str The attached databasae comment.
    refs tuple[str] The referenced table and field name or null for both.
get(*keys)

Get entries at keys.

shibas = client.tables.pets.get('Dog', 'Shiba Inu')
create(*keys, **data)

Insert new rows and return their respective entries.

created = await client.tables.pets.create('Cat', 'Persian', 'Robert')
created = await (
    client.tables.pets
    .create('Bird', 'Cockatiel', 'Tiko')
    .create('Bird', 'Conure', name = 'Ari', color = 255)
    .create('Hamster', breed = 'Syrian', name = 'Chops', groomed = True)
)

Uses an awaitable object leading to results.

update(*keys, **data)

Update entries at keys with data.

updated = await client.tables.pets.update('Lizard', 'Tegu', 'Rango', color = 65280)

Uses an awaitable object leading to results.

delete(*keys)

Delete entries at keys.

deleted = await client.tables.pets.delete('Insect', 'Mosquito')

Uses an awaitable object leading to results.