Package cjklib :: Module build :: Class TableBuilder
[hide private]
[frames] | no frames]

Class TableBuilder

source code


TableBuilder provides the abstract layout for classes that build a distinct table.

Instance Methods [hide private]
 
__init__(self, dataPath=None, dbConnectInst=None, quiet=False)
Constructs the TableBuilder.
source code
 
build(self)
Build the table provided by the TableBuilder.
source code
 
remove(self)
Removes the table provided by the TableBuilder from the database.
source code
str
findFile(self, fileNames, fileType=None)
Tries to locate a file with a given list of possible file names under the classes default data paths.
source code
 
buildTableObject(self, tableName, columns, columnTypeMap={}, primaryKeys=[])
Returns a SQLAlchemy Table object.
source code
object
buildIndexObjects(self, tableName, indexKeyList)
Returns a SQLAlchemy Table object.
source code

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

Class Variables [hide private]
  PROVIDES = ''
Contains the name of the table provided by this module.
  DEPENDS = []
Contains the names of the tables needed for the build process.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, dataPath=None, dbConnectInst=None, quiet=False)
(Constructor)

source code 

Constructs the TableBuilder.

Parameters:
  • dataPath (list of str) - optional list of paths to the data file(s)
  • dbConnectInst (instance) - instance of a DatabaseConnector. If not given all sql code will be printed to stdout.
  • quiet (bool) - if true no status information will be printed to stderr
Overrides: object.__init__

build(self)

source code 

Build the table provided by the TableBuilder.

Methods should raise an IOError if reading a data source fails. The DatabaseBuilder knows how to handle this case and is able to proceed.

findFile(self, fileNames, fileType=None)

source code 

Tries to locate a file with a given list of possible file names under the classes default data paths.

For each file name every given path is checked and the first match is returned.

Parameters:
  • fileNames (str/list of str) - possible file names
  • fileType (str) - textual type of file used in error msg
Returns: str
path to file of first match in search for existing file
Raises:
  • IOError - if no file found

buildTableObject(self, tableName, columns, columnTypeMap={}, primaryKeys=[])

source code 

Returns a SQLAlchemy Table object.

Parameters:
  • tableName (str) - name of table
  • columns (list of str) - column names
  • columnTypeMap (dict of str and object) - mapping of column name to SQLAlchemy Column
  • primaryKeys (list of str) - list of primary key columns

buildIndexObjects(self, tableName, indexKeyList)

source code 

Returns a SQLAlchemy Table object.

Parameters:
  • tableName (str) - name of table
  • indexKeyList (list of list of str) - a list of key combinations
Returns: object
SQLAlchemy Index