bci.saver package

Submodules

bci.saver.saver module

class bci.saver.saver.Saver(db_url=None, setup=None)

Bases: object

Represents a database saver.

db_url

URL of the running database.

Type

str

Parameters
  • db_url (str, optional) – URL of the running database. Default to DEFAULT_DB_URL.

  • setup (bool) – If true, setups the running database. Default to DEFAULT_SETUP.

close()
get(endpoint, str_dates=None, **kwargs)

Gets the rows corresponding to the specified API endpoint from the database.

Parameters
  • endpoint (str) – API endpoint.

  • str_dates (bool) – If true, converts the dates in the result to str, according to the appropriate format. Default to DEFAULT_STR_DATES.

  • kwargs (dict) – enpoint’s arguments

Returns

A dictionary representation of the required rows.

Return type

dict

Raises

ValueError – If endpoint is unknown.

save(topic, data)

Saves data under topic in the database.

Parameters
  • topic (str) – Topic name.

  • data (str) – JSON-formatted raw data, as consumed from the message queue. The data contains the result received from the topic parser as well as the corresponding snapshot and user information.

Module contents

class bci.saver.Saver(db_url=None, setup=None)

Bases: object

Represents a database saver.

db_url

URL of the running database.

Type

str

Parameters
  • db_url (str, optional) – URL of the running database. Default to DEFAULT_DB_URL.

  • setup (bool) – If true, setups the running database. Default to DEFAULT_SETUP.

close()
get(endpoint, str_dates=None, **kwargs)

Gets the rows corresponding to the specified API endpoint from the database.

Parameters
  • endpoint (str) – API endpoint.

  • str_dates (bool) – If true, converts the dates in the result to str, according to the appropriate format. Default to DEFAULT_STR_DATES.

  • kwargs (dict) – enpoint’s arguments

Returns

A dictionary representation of the required rows.

Return type

dict

Raises

ValueError – If endpoint is unknown.

save(topic, data)

Saves data under topic in the database.

Parameters
  • topic (str) – Topic name.

  • data (str) – JSON-formatted raw data, as consumed from the message queue. The data contains the result received from the topic parser as well as the corresponding snapshot and user information.