DatabaseManager module

class DatabaseManager.DbMan(credentials, dB)[source]

Bases: object

The dbMan class represents a single database accessed across a specific MySQL connector. It is initialised by passing a set of credentials for opening a connection to a MySQL server; these credentials are passed as a dictionary which defines the values for the ‘user’, ‘password’, ‘host’, ‘port’ and ‘database’ variables to be used to access an existing database on a MySQL server and the value of the ‘raise_on_warnings’ flag to be used over the connection to that database. The class supports new table, query and update functions which operate on the database, and ‘serverInfo’ and ‘close’ functions which operate on the connection. Work ongoing!

close()[source]
createTable(tableName, tableColumns)[source]
dropTable(table)[source]
listTables()[source]
queryTable(sqlCode)[source]
singleupdateTable(sqlCode, data)[source]
updateTable(sqlCode, data)[source]
class DatabaseManager.SvrMan(credentials)[source]

Bases: object

The SvrMan class represents a single server accessed across a specific MySQL connector. It is initialised by passing a set of credentials for opening a connection to a MySQL server; these credentials are passed as a dictionary which defines the values for the ‘user’, ‘password’, ‘host’, and ‘port’ variables to be used to access an existing database on a MySQL server and the value of the ‘raise_on_warnings’ flag to be used over the connection to that database. The class supports new table, query and update functions which operate on the database, and ‘serverInfo’ and ‘close’ functions which operate on the connection. Work ongoing!

..todo: Really DbmMan should ‘inherit from’ SvrMan. Need to work out how inheritance works in python.

close()[source]
createDatabase(dB)[source]
dropDatabase(dB)[source]
listDatabases()[source]
serverInfo()[source]
class DatabaseManager.table(content)[source]

Bases: object

A Table class object contains the column definitions of the table that it has been instantiated to represent. The column structure has to be provided as a tuple of tuples, each individual tuple being constituted of three strings that specify the column name, datatype and datatype again expressed as a % term (mostly %s)

A table object includes a createSQL() function which returns the SQL code to create the table, and insertSQL which returns the SQL code to insert

Parameters:content (tuple of tuples of strs) – Set of options to be presented to the user, defaults to (no default option)
createSQL()[source]
insertSQL()[source]