Welcome to querydb’s documentation!



class querydb.querydb.QueryDB(host='', port='5432', username='ml', password='YtTbR3UBiDN9DaEf', database_name='chronicles')

A class to submit queries in Chronicles PostgreSQL database.


Connects to the Chronicles PostgreSQL database.

custom_query(sql_query, data=None)

Opens a connection to the database, executes a custom SQL query supplied by the user and returns all fetched rows of the result.

  • sql_query (str) – The SQL query to execute, e.g., “SELECT COUNT(*) FROM “Acc” LIMIT 1000”

  • data – Parameters to be bound to variables in the operation.


A list with the rows of the query result.


Commits any pending transactions to the database and then closes the connection.


Returns Bluetooth timestamps, mac addresses, names and RSSI values for user_id.


user_id (str) – The user’s id, e.g. ‘CHR01-00002-GR1’.


A list containing tuples of timestamp in microseconds, device’s mac address, name and RSSI (Received Signal Strength Indicator). E.g., [(1628683227359681, ‘98:06:3C:E2:F2:8F’, ‘Samsung’, -58), …]


Returns a list of tuples with the first element of the tuple being the timestamp a recording event initiated and the second element being the timestamp the same recording event ended.


user_id (str) – The id of the user, e.g., ‘CHR01-00002-GR1’.

get_sensor_data(sensor_name, user_id, from_timestamp=None, to_timestamp=None, since=None)

Returns the data for sensor_name of user user_id.

  • sensor_name (str) – The name of the sensor whose data we want. Valid values include ‘Acc’, ‘Gyro’, ‘GyroUncalibrated’, ‘Hrm’, ‘Light’, ‘Linacc’, ‘Location’, ‘Magn’, ‘Motion’, ‘Pedometer’, ‘Ppg’, ‘Pressure’

  • user_id (str) – The id of the user, e.g., ‘CHR01-00002-GR1’.

  • from_timestamp (int) – Timestamp of Unix epoch time in microseconds after which to return data.

  • to_timestamp (int) – Timestamp of Unix epoch time in microseconds up until to return data.

  • since (datetime.timedelta) – The time interval since when we would like to fetch data, up until the present time. E.g., get_sensor_data(…, …, datetime.timedelta(days=3)) will return the data of the last 3 days.

  • arguments from_timestamp and to_timestamp are mutually (The) –

  • with since. So (exclusive) –

  • them both will throw an exception. (setting) –

  • Returns – A list of tuples with the respective data.


Returns a list of all the users in the database that have submitted files for processing.

Indices and tables