Home | Trees | Indices | Help |
|
---|
|
object --+ | ligolw.Element --+ | ligolw.EmptyElement --+ | ligolw.Table --+ | object --+ | | | list --+ | table.Table --+ | DBTable
A special version of the Table class using an SQL database for storage. Many of the features of the Table class are not available here, but instead the user can use SQL to query the table's contents.
The constraints attribute can be set to a text string that will be added to the table's CREATE statement where constraints go, for example you might wish to set this to "PRIMARY KEY (event_id)" for a table with an event_id column.
Note: because the table is stored in an SQL database, the use of this class imposes the restriction that table names be unique within a document.
Also note that at the present time there is really only proper support for the pre-defined tables in the lsctables module. It is possible to load unrecognized tables into a database from LIGO Light Weight XML files, but without developer intervention there is no way to indicate the constraints that should be imposed on the columns, for example which columns should be used as primary keys and so on. This can result in poor query performance. It is also possible to extract a database' contents to a LIGO Light Weight XML file even when the database contains unrecognized tables, but without developer intervention the column types will be guessed using a generic mapping of SQL types to LIGO Light Weight types.
Each instance of this class must be connected to a database. The (Python DBAPI 2.0 compatible) connection object is passed to the class via the connection parameter at instance creation time.
Example:
>>> import sqlite3 >>> connection = sqlite3.connection() >>> tbl = dbtables.DBTable(AttributesImpl({u"Name": u"process:table"}), connection = connection)
A custom content handler must be created in order to pass the connection keyword argument to the DBTable class when instances are created, since the default content handler does not do this. See the use_in() function defined in this module for information on how to create such a content handler
If a custom glue.ligolw.Table subclass is defined in glue.ligolw.lsctables whose name matches the name of the DBTable being constructed, the lsctables class is added to the list of parent classes. This allows the lsctables class' methods to be used with the DBTable instances but not all of the methods will necessarily work with the database-backed version of the class. Your mileage may vary.
|
|||
Inherited from |
|
|||
new empty list |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from |
|
|||
Inherited from Inherited from |
|
|||
a new object with type S, a subtype of T |
|
|
|||
Inherited from Inherited from Inherited from |
|
|||
Inherited from Inherited from Inherited from |
|
Initialize
|
iter(x)
|
len(x)
|
|
Standard .append() method. This method is for intended for internal use only. |
Called during parsing to indicate that the last Column child element has been added. Subclasses can override this to perform any special action that should occur following the addition of the last Column element.
|
Called during parsing to indicate that the last row has been added. Subclasses can override this to perform any special action that should occur following the addition of the last row.
|
Replacement for the standard .append() method. This version performs on the fly row ID reassignment, and so also performs the function of the updateKeyMapping() method. SQLite does not permit the PRIMARY KEY of a row to be modified, so it needs to be done prior to insertion. This method is intended for internal use only. |
Given an iterable of values in the order of columns in the database, construct and return a row object. This is a convenience function for turning the results of database queries into Python objects. |
Standard .append() method. This method is for intended for internal use only.
|
Used as the second half of the key reassignment algorithm. Loops over each row in the table, replacing references to old row keys with the new values from the _idmap_ table.
|
This method is not implemented. See glue.ligolw.table.Table for more information.
|
Given an iterable of values in the order of columns in the database, construct and return a row object. This is a convenience function for turning the results of database queries into Python objects. |
Determines the highest-numbered ID in this table, and sets the table's .next_id attribute to the next highest ID in sequence. If the .next_id attribute is already set to a value greater than the highest value found, then it is left unmodified. The return value is the ID identified by this method. If the table's .next_id attribute is None, then this function is a no-op. Note that tables of the same name typically share a common .next_id attribute (it is a class attribute, not an attribute of each instance) so that IDs can be generated that are unique across all tables in the document. Running sync_next_id() on all the tables in a document that are of the same type will have the effect of setting the ID to the next ID higher than any ID in any of those tables. Example: >>> import lsctables >>> tbl = lsctables.New(lsctables.ProcessTable) >>> print(tbl.sync_next_id()) process:process_id:0
|
Break internal references within the document tree rooted on this element to promote garbage collection.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Dec 12 00:34:18 2017 | http://epydoc.sourceforge.net |