Package gavo :: Package rsc :: Module qtable :: Class QueryTable
[frames] | no frames]

Class QueryTable

source code

                            object --+        
                                     |        
                   base.meta.MetaMixin --+    
                                         |    
                            object --+   |    
                                     |   |    
                     common.ParamMixin --+    
                                         |    
                           table.BaseTable --+
                                             |
                        object --+           |
                                 |           |
base.sqlsupport.PostgresQueryMixin --+       |
                                     |       |
                        object --+   |       |
                                 |   |       |
base.sqlsupport.StandardQueryMixin --+       |
                                     |       |
          base.sqlsupport.QuerierMixin --+   |
                                         |   |
                    dbtable.DBMethodsMixin --+
                                             |
                                            QueryTable

QueryTables are constructed with a table definition and a DB query feeding this table definition.

A QueryTable must be constructed with a connection. If you pass autoClose=True, it will close this connection after the data is delivered.

This funky semantics is for the benefit of taprunner; it needs a connection up front for uploads.

There's an alternative constructor allowing "quick" construction of the result table (fromColumns).

Instance Methods
 
__init__(self, tableDef, query, connection, **kwargs)
is a constructor for standalone use.
source code
 
__iter__(self)
actually runs the query and returns rows (dictionaries).
source code
 
__len__(self) source code
 
cleanup(self) source code
 
getPlan(self)
returns a parsed query plan for the current query.
source code
 
__del__(self) source code

Inherited from table.BaseTable: addRow, addTuple, close, getFeeder, getRow, importFailed, importFinished, removeRow, runScripts, validateParams

Inherited from base.meta.MetaMixin: addMeta, buildRepr, copyMetaFrom, delMeta, getAllMetaPairs, getMeta, getMetaKeys, getMetaParent, isEmpty, iterMeta, keys, makeOriginal, setMeta, setMetaParent, traverse

Inherited from common.ParamMixin: getParam, getParamByName, getParamByUtype, getParamDict, iterParams, setParam, setParams

Inherited from dbtable.DBMethodsMixin: copyIn, copyOut, deleteMatching, dropIndices, ensureOnDiskMatches, ensureSchema, getDeleteQuery, makeIndices

Inherited from base.sqlsupport.QuerierMixin: abort, configureConnection, enableAutocommit, finish, query, queryDicts, queryToDicts

Inherited from base.sqlsupport.PostgresQueryMixin: dropTable, foreignKeyExists, getACLFromRes, getColumnsFromDB, getForeignKeyName, getOIDForTable, getPrimaryIndexName, getRowEstimate, getSchemaPrivileges, getServerVersion, getTablePrivileges, getTableType, hasIndex, parsePGACL, roleExists, schemaExists

Inherited from base.sqlsupport.StandardQueryMixin: getTimeout, setSchemaPrivileges, setTablePrivileges, setTimeout

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
fromColumns(cls, colSpec, query, connection, **kwargs)
returns a QueryTable object for query, where the result table is inferred from colSpec.
source code
Class Variables
  connection = None
hash(x)

Inherited from dbtable.DBMethodsMixin: scripts

Inherited from base.sqlsupport.QuerierMixin: defaultProfile

Properties

Inherited from object: __class__

Method Details

__init__(self, tableDef, query, connection, **kwargs)
(Constructor)

source code 

is a constructor for standalone use. You do *not* want to call this when mixing into a Structure.

Overrides: object.__init__
(inherited documentation)

fromColumns(cls, colSpec, query, connection, **kwargs)
Class Method

source code 

returns a QueryTable object for query, where the result table is inferred from colSpec.

colSpec is a sequence consisting of either dictionaries with constructor arguments to rscdef.Column or complete objects suitable as rscdef.Column objects; futher kwargs are passed on the the QueryTable's constructor.

__iter__(self)

source code 

actually runs the query and returns rows (dictionaries).

You can only iterate once. At exhaustion, the connection will be closed.

Overrides: table.BaseTable.__iter__

__len__(self)
(Length operator)

source code 
Overrides: table.BaseTable.__len__

getPlan(self)

source code 

returns a parsed query plan for the current query.

After you use this method, the iterator is exhausted and the connection will be closed.