MdbTicFactory

MdbTicFactory(self, tic_dat_factory)

Primary class for reading/writing Access/MDB files with TicDat objects.

Don't create this object explicitly. A MdbTicDatFactory will automatically be associated with the mdb attribute of the parent TicDatFactory.

Your system will need the pypyodbc package if you want to actually do something with it.

can_write_new_file

:return: True if this environment can write to a new mdb database files, False otherwise

create_tic_dat

MdbTicFactory.create_tic_dat(mdb_file_path, freeze_it=False)

Create a TicDat object from an Access MDB file

:param mdb_file_path: An Access 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 : Tables that don't find a match are interpreted as an empty table. Missing fields on matching tables throw an exception. Also, see infinity_io_flag

find_duplicates

MdbTicFactory.find_duplicates(mdb_file_path)

Find the row counts for duplicated rows.

:param mdb_file_path: An Access 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 mdb table with this primary key. Row counts smaller than 2 are pruned off, as they aren't duplicates

write_schema

MdbTicFactory.write_schema(mdb_file_path, **field_types)

Populate an Access file with a database schema

:param mdb_file_path: The file path of the mdb database to create

:param field_types: Named arguments are table names. Argument values are mapping of field name to field type. Allowable field types are text, double and int If missing, primary key fields are text, and data fields are double :return:

write_file

MdbTicFactory.write_file(tic_dat, mdb_file_path, allow_overwrite=False)

write the ticDat data to an SQLite database file

:param tic_dat: the data object to write

:param mdb_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 : See infinity_io_flag

NB - thrown Exceptions of the form "Data type mismatch in criteria expression" generally result either from Access's inability to store different data types in the same field, or from a mismatch between the data object and the default field types ticdat uses when creating an Access schema. For the latter, feel free to call the write_schema function on the data file first with explicitly identified field types.