database (class)

class fundamentals.mysql.database(log, dbSettings=False, autocommit=True)[source][source]

Bases: object

a database object that can setup up a ssh tunnel (optional) and a database connection

Key Arguments

  • log – logger

  • dbSettings – a dictionary of database settings

Return

  • dbConns – a database connection

Usage

Given a python dictionary that looks like this:

```python 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 and tunnel are optional, to setup the a database connection, run the following:

```python # SETUP ALL DATABASE CONNECTIONS from fundamentals.mysql import database dbConn = database(

log=log, dbSettings=dbSettings

).connect() ```

Methods

connect()[source][source]

Connect to the database

Return

  • dbConn – the database connection

See the class docstring for usage