| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
base.sqlsupport.PostgresQueryMixin --+
|
object --+ |
| |
base.sqlsupport.StandardQueryMixin --+
|
base.sqlsupport.QuerierMixin --+
|
DBMethodsMixin --+
|
object --+ |
| |
base.meta.MetaMixin --+ |
| |
object --+ | |
| | |
common.ParamMixin --+ |
| |
table.BaseTable --+
|
object --+ |
| |
MetaTableMixin --+
|
DBTable
An interface to a table in the database.
These are usually created using ``api.TableForDef(tableDef)`` with a
table definition obtained, e.g., from an RD, saying ``onDisk=True``.
When constructing a DBTable, it will be created if necessary (unless
``create=False`` is passed), but indices or primary keys keys will only be
created on a call to ``importFinished``.
The constructor does not check if the schema of the table on disk matches
the tableDef. If the two diverge, all kinds of failures are conceivable;
use ``dachs val -c`` to make sure on-disk structure match the RDs.
You can pass a ``nometa`` boolean kw argument to suppress entering the table
into the ``dc_tables`` table.
You can pass an exclusive boolean kw argument; if you do, the
``iterQuery`` (and possibly similar methods in the future) method
will block concurrent writes to the selected rows ("FOR UPDATE")
as long as the transaction is active.
The main attributes (with API guarantees) include:
* tableDef -- the defining tableDef
* getFeeder() -- returns a function you can call with rowdicts to
insert them into the table.
* importFinished() -- must be called after you've fed all rows when
importing data.
* drop() -- drops the table in the database
* recreate() -- drops the table and generates a new empty one.
* getTableForQuery(...) -- returns a Table instance built from a query
over this table (you probably to use ``conn.query*`` and
``td.getSimpleQuery`` instead).
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from |
|||
| Class Variables | |
|
Inherited from Inherited from |
| Properties | |
|
Inherited from |
| Method Details |
is a constructor for standalone use. You do *not* want to call this when mixing into a Structure.
|
|
|
|
|
|
Feeds a sequence of rows to the table. The method returns the number of rows affected. Exceptions are handed through upstream, but the connection is rolled back. |
adds a row to the table. Use this only to add one or two rows, otherwise go for getFeeder.
|
returns the row with the primary key key from the table. This will raise a DataError on tables without primaries.
|
runs query within this table's connection. query is macro-expanded within the table definition (i.e., you can, e.g., write \qName to obtain the table's qualified name).
|
returns a result table definition, query string and a parameters dictionary for a query against this table. See getTableForQuery for the meaning of the arguments. |
like getTableForQuery, except that an iterator over the result rows is returned. (there is no advantage in using this as we will pull the entire thing in memory anyway; use qtables if you need streaming). |
returns a Table instance for a query on this table. resultTableDef is a TableDef with svc.OutputField columns (rscdef.Column instances will do), or possibly just a list of Columns. Fragment is empty or an SQL where-clause with dictionary placeholders, pars is the dictionary filling fragment, distinct, if True, adds a distinct clause, and limits, if given, is a pair of an SQL string to be appended to the SELECT clause and parameters filling it. queryMeta.asSQL returns what you need here. pars may be mutated in the process. |
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Thu May 2 07:29:09 2019 | http://epydoc.sourceforge.net |