import sqlite3
from database import db

class DrDb:
    def __init__(self, filename):
        """
        ! Constructor of the app Config class
        @param filename Name of the config INI file to load
        """
        self.engine = None
        self.connection = None
        self.metadata = db.MetaData()

        self.engine = db.create_engine('sqlite:///' + filename)
        self.connection = self.engine.connect()

        metadata = db.MetaData()
        offense_sources = db.Table('offense_sources', metadata, autoload=True, autoload_with=self.engine)
        self.query = db.select([offense_sources])
        result_proxy = self.connection.execute(self.query)
        result_set = result_proxy.fetchall()
        print(result_set)


    def isSQLite3(self, filename):
        from os.path import isfile, getsize

        if not isfile(filename):
            return False

        return True
