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 0strcreate,updateordelete.1strTable name. 2tuple[Entry]Single entries or (old, new)pairs (updateonly).
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 namestrIts name. mainboolWhether this is a primary key. typestrPostgreSQL type name. dimsintNumber of array dimensions. nullboolWhether this is nullable. infostrThe attached databasae comment. refstuple[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
keyswithdata.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.