API Documentation

Tables (neurobooth_terra):

Table(table_id, conn[, cursor, primary_key])

Table class that is a wrapper around Postgres SQL table.

create_table(table_id, conn, column_names, …)

Create a table.

drop_table(table_id, conn)

Drop table.

list_tables(conn)

List the table_ids in the database.

query(conn, sql_query, column_names)

Transform a SELECT query into a pandas dataframe

Redcap (neurobooth_terra.redcap)

These are general redcap functions.

fetch_survey(project, survey_name, survey_id)

Get schema of table from redcap

dataframe_to_tuple(df, df_columns[, …])

Extract pandas dataframe into tuples for ingestion in Postgres.

rename_subject_ids(table_subject, redcap_df)

Rename subject_id in table_subject using data in redcap_df.

Data dictionary

These are functions related to processing data dictionary

extract_field_annotation(s)

Extract the field annotation and create new columns for them

map_dtypes(s)

Create new columns mapping Redcap data types to Postgres and Python.

get_response_array(s)

Add response array dictionary mapping answer choices to answer text.

get_tables_structure(metadata[, include_surveys])

Get the column names and datatypes for the tables.

subselect_table_structure(table_info, df_cols)

Subselect columns that are in the report.

Data flow

write_file(sensor_file_table, db_table, fname)

Write a file.

transfer_files(src_dir, dest_dir, db_table, …)

Transfer files using rsync.

delete_files(db_table, target_dir, …[, …])

Delete files if x% of disk is filled.