SQLiteTicFactory

SQLiteTicFactory(self, tic_dat_factory)

Primary class for reading/writing SQLite files with TicDat objects. Don't create this object explicitly. A SQLiteTicFactory will automatically be associated with the sql attribute of the parent TicDatFactory. You need the sqlite3 package to be installed to use it.

create_tic_dat

SQLiteTicFactory.create_tic_dat(db_file_path, freeze_it=False)

Create a TicDat object from a SQLite database file

:param db_file_path: A SQLite db with a consistent schema.

:param freeze_it: boolean. should the returned object be frozen?

:return: a TicDat object populated by the matching tables.

caveats : "inf" and "-inf" (case insensitive) are read as floats, unless the infinity_io_flag is being applied. "true"/"false" (case insensitive) are read as booleans booleans. Tables that don't find a match are interpreted as an empty table. Missing fields on matching tables throw an exception.

create_tic_dat_from_sql

SQLiteTicFactory.create_tic_dat_from_sql(sql_file_path,
                                         includes_schema=False,
                                         freeze_it=False)

Create a TicDat object from an SQLite sql text file

:param sql_file_path: A text file containing SQLite compatible SQL statements delimited by ;

:param includes_schema: boolean - does the sql_file_path contain schema generating SQL?

:param freeze_it: boolean. should the returned object be frozen?

:return: a TicDat object populated by the db created from the SQL. See create_tic_dat for caveats.

find_duplicates

SQLiteTicFactory.find_duplicates(db_file_path)

Find the row counts for duplicated rows.

:param db_file_path: A SQLite db with a consistent schema.

:return: A dictionary whose keys are table names for the primary-ed key tables. Each value of the return dictionary is itself a dictionary. The inner dictionary is keyed by the primary key values encountered in the table, and the value is the count of records in the SQLite table with this primary key. Row counts smaller than 2 are pruned off, as they aren't duplicates

write_db_schema

SQLiteTicFactory.write_db_schema(db_file_path)

:param db_file_path: the file path of the SQLite database to create

:return:

write_db_data

SQLiteTicFactory.write_db_data(tic_dat,
                               db_file_path,
                               allow_overwrite=False)

write the ticDat data to an SQLite database file

:param tic_dat: the data object to write

:param db_file_path: the file path of the SQLite database to populate

:param allow_overwrite: boolean - are we allowed to overwrite pre-existing data

:return:

caveats : True, False are written as "True", "False". Also see infinity_io_flag doc

write_sql_file

SQLiteTicFactory.write_sql_file(tic_dat,
                                sql_file_path,
                                include_schema=False,
                                allow_overwrite=False)

write the sql for the ticDat data to a text file

:param tic_dat: the data object to write

:param sql_file_path: the path of the text file to hold the sql statements for the data

:param include_schema: boolean - should we write the schema sql first?

:param allow_overwrite: boolean - are we allowed to overwrite pre-existing file

:return:

caveats : float("inf"), float("-inf") are written as "inf", "-inf" (unless infinity_io_flag is being applied). True/False are written as "True", "False"