Example #1
0
# importing sqlite 3 for database operations
import sqlite3
from lib.AppConstants import AppConstants
from lib.AppLogger import get_reporting_logger

logging = get_reporting_logger()


# creating connection and cursor objects
def initialiseDB():
    con = sqlite3.connect(AppConstants.DB_FILE)
    c = con.cursor()
    return con, c


def terminateDB(con):
    con.close()


def fetchAllServer():
    logging.info("Reading all server info from DB")
    try:
        con, c = initialiseDB()
        c.execute("select * from servers")
    except Exception as e:
        logging.error(str(e))
    data = c.fetchall()
    terminateDB(con)
    logging.info("Returning all servers info")
    return data
 def __init__(self):
     self.logging = get_reporting_logger()
     self.container = AppConstants.CONTAINER