# Path: Database/db_controller.py
# class db_settings():
# class SettingsHelper(db_settings):
# class db_access(SettingsHelper, object):
# class db_helper(db_access):
#     USERNAME = 'postgres'
#     DB_HOST = '127.0.0.1'
#     PORT = 5432
#     DATABASE = 'network_monitor'
#     SETTINGS_FILE_PATH = "database_settings.json"
#     KEYRING_APP_ID = 'NetworkMonitor_db'
#         DB_HOST = raw_input('({0})>'.format(self.DB_HOST))
#     def loadSettings(cls):
#     def saveSettings(cls):
#     def __init__(self):
#     def open_connection(self):
#     def close_connection(connection, cursor):
#     def __init__(self):
#     def __create_database(self):
#     def __create_tables(self):
#     def test_db_setup(self):
#     def configure(self):
#     def clear_password_store(self):


import logging
from datetime import datetime
from Database import db_controller
"""
Provides a easy way for accessing all needed database functions
"""


__author__ = 'Jesse'



class server_stats(object):
    @staticmethod
    def failures_in_x_minutes_ago(last_x_minutes_of_failures):
        """ Returns list of failures from variable"""
        conn, cur = db_controller.db_access().open_connection()
        query = '''SELECT * FROM server_stats WHERE time_stamp >= (now() - '{0} minute'::INTERVAL) ORDER BY time_stamp DESC;'''
        cur.execute(query.format(last_x_minutes_of_failures))

# Path: Database/db_controller.py
# class db_settings():
# class SettingsHelper(db_settings):
# class db_access(SettingsHelper, object):
# class db_helper(db_access):
#     USERNAME = 'postgres'
#     DB_HOST = '127.0.0.1'
#     PORT = 5432
#     DATABASE = 'network_monitor'
#     SETTINGS_FILE_PATH = "database_settings.json"
#     KEYRING_APP_ID = 'NetworkMonitor_db'
#         DB_HOST = raw_input('({0})>'.format(self.DB_HOST))
#     def loadSettings(cls):
#     def saveSettings(cls):
#     def __init__(self):
#     def open_connection(self):
#     def close_connection(connection, cursor):
#     def __init__(self):
#     def __create_database(self):
#     def __create_tables(self):
#     def test_db_setup(self):
#     def configure(self):
#     def clear_password_store(self):


# Path: Database/db_helpers.py
import logging
from datetime import datetime
from Database import db_controller

"""
Provides a easy way for accessing all needed database functions
"""


__author__ = 'Jesse'



class server_stats(object):
    @staticmethod
    def failures_in_x_minutes_ago(last_x_minutes_of_failures):
        """ Returns list of failures from variable"""
        conn, cur = db_controller.db_access().open_connection()
        query = '''SELECT * FROM server_stats WHERE time_stamp >= (now() - '{0} minute'::INTERVAL) ORDER BY time_stamp DESC;'''
        cur.execute(query.format(last_x_minutes_of_failures))

        data = cur.fetchall()