def __init__(self, datasource=None, channel=None, page=0):
    self.conn = None
    if (datasource == None):
        return None
    self.db = None
    self.channel = channel
    self.page = page
    try:
        self.db = MySQLdb.connect(user=DB_USER, passwd=DB_PASS, db=DB_NAME, host=DB_HOST, port=DB_PORT)
    except Exception as e:
        raise Exception((('DBLogger was unable to connect to the database: ' + '(error %d): %s (Note: connection values should be in config.py).') + ('error %s' % e)))
    if (self.db == None):
        raise Exception('DBLogger: Unable to connect to database.')
    self.conn = self.db.cursor()
    self.conn.execute('SELECT ds_id FROM datasources WHERE ds_name LIKE %s LIMIT 1', (datasource,))
    if (self.conn.rowcount == 1):
        self.ds_id = self.conn.fetchone()
    else:
        print('No datasource found matching name:', datasource)
def __init__(self, datasource=None, channel=None, page=0):
    self.conn = None
    if (datasource == None):
        return None
    self.db = None
    self.channel = channel
    self.page = page
    try:
        self.db = MySQLdb.connect(user=DB_USER, passwd=DB_PASS, db=DB_NAME, host=DB_HOST, port=DB_PORT)
    except Exception as e:
        raise Exception((('DBLogger was unable to connect to the database: ' + '(error %d): %s (Note: connection values should be in config.py).') + ('error %s' % e)))
    if (self.db == None):
        raise Exception('DBLogger: Unable to connect to database.')
    self.conn = self.db.cursor()
    self.conn.execute('SELECT ds_id FROM datasources WHERE ds_name LIKE %s LIMIT 1', (datasource,))
    if (self.conn.rowcount == 1):
        self.ds_id = self.conn.fetchone()
    else:
        print('No datasource found matching name:', datasource)