database (class) ∞
-
class
database
(log, dbSettings=False, autocommit=True)[source] ∞ Bases:
object
a database object that can setup up a ssh tunnel (optional) and a database connection
Key Arguments
log
– loggerdbSettings
– a dictionary of database settings
Return
dbConns
– a database connection
Usage
Given a python dictionary that looks like this:
dbSettings = { 'host': '127.0.0.1', 'loginPath': 'atlasMovers', 'user': 'monster', 'tunnel': { 'remote ip': 'psweb.mp.qub.ac.uk', 'remote datbase host': 'dormammu', 'remote user': 'monster', 'port': 9006 }, 'password': 'myPass', 'db': 'atlas_moving_objects' }
loginPath
andtunnel
are optional, to setup the a database connection, run the following:# SETUP ALL DATABASE CONNECTIONS from fundamentals.mysql import database dbConn = database( log=log, dbSettings=dbSettings ).connect()
Methods
connect
()Connect to the database