idmapper

class igwn_ligolw.dbtables.idmapper(connection)

Bases: object

Create and manage the _idmap_ table in an sqlite database. This table has columns “table_name”, “old”, and “new” mapping old IDs to new IDs for each table. The (table_name, old) column pair is a primary key (is indexed and must contain unique entries). The table is created as a temporary table, so it will be automatically dropped when the database connection is closed.

This class is for internal use, it forms part of the code used to re-map row IDs when merging multiple documents.

Methods Summary

get_new(cursor, table_name, old, tbl)

From the old ID, obtain a replacement ID by either grabbing it from the _idmap_ table if one has already been assigned to the old ID, or by using the current value of the Table instance's next_id class attribute.

reset()

Erase the contents of the _idmap_ table, but leave the table in place.

sync()

Iterate over the tables in the database, ensure that there exists a custom DBTable class for each, and synchronize that table's ID generator to the ID values in the database.

update_ids(xmldoc[, verbose])

Methods Documentation

static get_new(cursor, table_name, old, tbl)

From the old ID, obtain a replacement ID by either grabbing it from the _idmap_ table if one has already been assigned to the old ID, or by using the current value of the Table instance’s next_id class attribute. In the latter case, the new ID is recorded in the _idmap_ table, and the class attribute incremented by 1.

reset()

Erase the contents of the _idmap_ table, but leave the table in place.

sync()

Iterate over the tables in the database, ensure that there exists a custom DBTable class for each, and synchronize that table’s ID generator to the ID values in the database.

update_ids(xmldoc, verbose=False)