Table Class

The table class represents a single MySQL table.

class pysk.db.Table(columns=None)

MySql table instance containing some meta information about a table

Parameters:columns – Iterable of pysk.db.Column instances storing information about a table column
appendColumn(col)

Insert a column into the table

Parameters:col (pysk.db.Column) – Column to insert
format()

Returns a tuple to be passed to INSERT INTO VALUES command.

Returns:format string
getColumnByName(name)

Get column with a given name

Parameters:name (string) – Column name to search for
Returns:pysk.db.Column instance with the given name. Raises a KeyError if no such column exists
iterColumnNames()

Iterate over column names

Returns:Generator over column names of this table
iterColumns(cls)

Iterates over the columns of a given object

The object must provide an attribute for each column in the current table.

Returns:Generator over the table columns filled with the values of cls
nColumns()

Get number of columns in this table

Returns:Number of columns in this table
toTuple(cls)

Convert class into tuple based on attributes.

Parameters:cls – Class containing an attribute with same name as each table column.
Returns:Tuple intended for insertion into table