Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
db.bll_database.BLLDatabase Class Reference

Provides BLL-app-specific data retreival and storage routines, building on the base database class. More...

Inheritance diagram for db.bll_database.BLLDatabase:

Public Member Functions

def __init__
 Constructor. More...
 
def apply_update_scripts
 Runs any sql scripts in UPDATE_SCRIPT_DIR that haven't been run yet. More...
 
def select_codes
 This method creates Code objects containing all the options for a particular type of code (transcriber, lena_notes, speaker). More...
 
def select_enum
 Builds an Enum based upon a selection from a particular property or table. More...
 
- Public Member Functions inherited from db.database.Database
def __init__
 Constructor. More...
 
def close
 Closes the database connection, releasing any resources that it was using. More...
 
def execute_stmt
 Executes a verbatim SQL statement. More...
 
def execute_script
 Reads and executes a sql script file. More...
 
def insert
 Inserts one or more rows into a table in the database. More...
 
def select
 Selects rows from a table in the database. More...
 
def delete
 Deletes rows from a table in the database. More...
 
def update_timestamp_col
 Updates the value of a timestamp column to the current date/time. More...
 
def update
 Updates rows in a table. More...
 
def write_to_file
 Writes out all of the data in a table to a csv file. More...
 

Static Public Attributes

string DB_LOCATION = 'db/bll_db.db'
 
string CREATE_TABLES_SCRIPT = 'db/sql/init/create_tables.sql'
 
string INSERT_DATA_SCRIPT = 'db/sql/init/insert_data.sql'
 
string UPDATE_SCRIPT_DIR = 'db/sql/updates/'
 
int NUM_TRANS_CODES = 4
 

Private Member Functions

def _get_speaker_types_enum
 Builds an Enum of recognized speaker types from the speaker_types table. More...
 
def _get_speaker_distances_enum
 Builds an enum of possible speaker 'distances' (eg. More...
 
def _get_speaker_props_enum
 Builds an Enum of possible speaker 'properties' (Eg. More...
 
def _get_combo_groups_enum
 Builds an Enum of all possible combo groups. More...
 
def _get_common_regexs_enum
 Builds an Enum of common regular expressions from the common_regex DB table. More...
 
def _get_combo_options_enum
 Builds a dictionary (of Enums - one for each combo group), containing all prossible combo box options that the UI can use. More...
 
def _get_settings_enum
 Builds an Enum of the application settings from the settings table. More...
 
def _select_transcriber_codes
 Builds a list of Code objects for transcriber codes. More...
 
def _select_lena_notes_codes
 Creates a Code object containing information about options from the lena_notes_codes table. More...
 
def _select_speaker_codes
 Creates a Code object containing information about options from the speaker_codes table. More...
 

Additional Inherited Members

- Public Attributes inherited from db.database.Database
 conn
 
 cursor
 

Detailed Description

Provides BLL-app-specific data retreival and storage routines, building on the base database class.

Constants needed for segment and utterance parsing/manipulation (lena speaker codes, transcriber codes, etc.), application-wide settings (info needed to launch Praat and Excel), common UI combobox options, and any associated information are retreived from database tables and put into Enums by routines in this class. The DBConstants class (see bottom of file) is populated using these methods. DBConstants' public attributes (Enums) can then be used anywhere in the application code.

Definition at line 18 of file bll_database.py.

Constructor & Destructor Documentation

def db.bll_database.BLLDatabase.__init__ (   self)

Constructor.

Parameters
self

Definition at line 27 of file bll_database.py.

Member Function Documentation

def db.bll_database.BLLDatabase._get_combo_groups_enum (   self)
private

Builds an Enum of all possible combo groups.

Each combo group corresponds to a single dropdown box in the UI, and maps to one or more combo options. The Enum is built from the combo_groups table.

Parameters
self
Returns
(Enum) attributes are from the 'code_name' column, values are from the 'id' column

Definition at line 114 of file bll_database.py.

def db.bll_database.BLLDatabase._get_combo_options_enum (   self)
private

Builds a dictionary (of Enums - one for each combo group), containing all prossible combo box options that the UI can use.

Parameters
self
Returns
(dictionary) a dictionary of Enums. The dictionary contains a key for each id from the combo_groups table. Each entry contains an Enum of all possible combo options for that group (Retreived from the combo_options table. Enum attributes are from the 'code_name' column, values are from the 'id' column).

Definition at line 132 of file bll_database.py.

def db.bll_database.BLLDatabase._get_common_regexs_enum (   self)
private

Builds an Enum of common regular expressions from the common_regex DB table.

Parameters
self
Returns
(Enum) attributes are from the 'code_name' column, values are from the 'id' column

Definition at line 123 of file bll_database.py.

def db.bll_database.BLLDatabase._get_settings_enum (   self)
private

Builds an Enum of the application settings from the settings table.

Parameters
self
Returns
(Enum) Enum attributes are from the 'code_name' column, values are from the 'id' column).

Definition at line 145 of file bll_database.py.

def db.bll_database.BLLDatabase._get_speaker_distances_enum (   self)
private

Builds an enum of possible speaker 'distances' (eg.

FAN speaker has distance of 'near', FAF speaker has distance of 'far', 'SIL' speaker has distance of 'not applicable').

Parameters
self
returns(Enum) attributes are 'NA, NEAR, FAR', values are 0, 1, 2 (respectively)

Definition at line 100 of file bll_database.py.

def db.bll_database.BLLDatabase._get_speaker_props_enum (   self)
private

Builds an Enum of possible speaker 'properties' (Eg.

speakers can be overlapping, be non-verbal noise, or be tv/radio sound)

Parameters
self
Returns
(Enum) attributes are 'MEDIA', 'OVERLAPPING', 'NON_VERBAL_NOISE', values are 0, 1, 2, (respectively)

Definition at line 107 of file bll_database.py.

def db.bll_database.BLLDatabase._get_speaker_types_enum (   self)
private

Builds an Enum of recognized speaker types from the speaker_types table.

These are derrived from transcriber code 1's possible options (see transcriber manual) like 'MALE_ADULT', 'FEMALE_ADULT', 'OTHER_CHILD', etc.

Parameters
self
Returns
(Enum) attributes are from code_name column, values from id column

Definition at line 91 of file bll_database.py.

def db.bll_database.BLLDatabase._select_lena_notes_codes (   self)
private

Creates a Code object containing information about options from the lena_notes_codes table.

('LENA notes codes' look like 'VOC', 'SIL', etc.)

Parameters
self
Returns
(Code) Code object that can be used to access info about different lena notes code options.

Definition at line 219 of file bll_database.py.

def db.bll_database.BLLDatabase._select_speaker_codes (   self)
private

Creates a Code object containing information about options from the speaker_codes table.

(LENA speaker codes like 'MAN', 'FAN', etc.)

Parameters
selfreturns (Code) a Code object that can be used to access info about different speaker code options.

Definition at line 242 of file bll_database.py.

def db.bll_database.BLLDatabase._select_transcriber_codes (   self)
private

Builds a list of Code objects for transcriber codes.

The Code objects contain information from the transcriber_codes database table.

Parameters
self
Returns
(list) list of Code objects, one for each transcriber code.

Definition at line 180 of file bll_database.py.

def db.bll_database.BLLDatabase.apply_update_scripts (   self)

Runs any sql scripts in UPDATE_SCRIPT_DIR that haven't been run yet.

In order to do this, scripts must follow a naming convention: "update-x.sql", where x is an integer. The files in UPDATE_SCRIPT_DIR are sorted by this integer before being applied. If previous update scripts have been applied, the last script number is recorded in the settings table. Only scripts with numbers greater than this number are applied when this method is called.

Parameters
self

Definition at line 49 of file bll_database.py.

def db.bll_database.BLLDatabase.select_codes (   self,
  table 
)

This method creates Code objects containing all the options for a particular type of code (transcriber, lena_notes, speaker).

Parameters
self
table(string) name of the table to select from.
Returns
(Code/list of Code) a Code object (or list of Code objects, if selecting transcriber codes) that contains code options and properties from the DB table

Definition at line 157 of file bll_database.py.

def db.bll_database.BLLDatabase.select_enum (   self,
  table 
)

Builds an Enum based upon a selection from a particular property or table.

Parameters
self
table(string) name of the table to select from
Returns
(Enum) an Enum with attributes for all of the options within the table (attributes are from the code_name column, values from the id column).

Definition at line 167 of file bll_database.py.

Member Data Documentation

string db.bll_database.BLLDatabase.CREATE_TABLES_SCRIPT = 'db/sql/init/create_tables.sql'
static

Definition at line 20 of file bll_database.py.

string db.bll_database.BLLDatabase.DB_LOCATION = 'db/bll_db.db'
static

Definition at line 19 of file bll_database.py.

string db.bll_database.BLLDatabase.INSERT_DATA_SCRIPT = 'db/sql/init/insert_data.sql'
static

Definition at line 21 of file bll_database.py.

int db.bll_database.BLLDatabase.NUM_TRANS_CODES = 4
static

Definition at line 23 of file bll_database.py.

string db.bll_database.BLLDatabase.UPDATE_SCRIPT_DIR = 'db/sql/updates/'
static

Definition at line 22 of file bll_database.py.


The documentation for this class was generated from the following file: