Beispiel #1
0
def temp_build_database(dbpath):

    # remove temp database
    if os.path.exists(dbpath):
        os.remove(dbpath)

    # connect to each database
    db = dbconnection.createConnection('sqlite', dbpath)
    db_instance = sqlite(db)

    return db_instance
Beispiel #2
0
def temp_build_database(dbpath):

    # remove temp database
    if os.path.exists(dbpath):
        os.remove(dbpath)

    # connect to each database
    db = dbconnection.createConnection('sqlite', dbpath)
    db_instance = sqlite(db)



    return db_instance
Beispiel #3
0
    def setUp(self):

        # define the paths for the empty and populated temp databases
        dirpath = os.path.dirname(os.path.abspath(__file__))
        self.empty_db_path = os.path.join(dirpath,'data/temp_empty.db')
        self.pop_db_path = os.path.join(dirpath, 'data/temp_pop.db')


        # remove temp databases
        if os.path.exists(self.empty_db_path):
            os.remove(self.empty_db_path)
        if os.path.exists(self.pop_db_path):
            os.remove(self.pop_db_path)

        # connect to each database
        empty_connection = dbconnection.createConnection('sqlite', self.empty_db_path)
        pop_connection = dbconnection.createConnection('sqlite', self.pop_db_path)

        self.emptysqlite = sqlite(empty_connection)
        self.popsqlite = sqlite(pop_connection)

        # initialize the in-memory database, loop through each command (skip first and last lines)
        empty_dump_script = open( os.path.join(dirpath, 'data/empty_dump.sql'),'r').read()
        for line in empty_dump_script.split(';\n'):
            self.emptysqlite.cursor.execute(line)

        populated_dump_script = open(os.path.join(dirpath, 'data/populated_dump.sql'),'r').read()
        for line in populated_dump_script.split(';\n'):
            self.popsqlite.cursor.execute(line)

        # initialize environment variables
        environment.getEnvironmentVars()
        if sys.gettrace():
            print 'Detected Debug Mode'
            # initialize debug listener (reroute messages to console)
            self.d = sprint.DebugListener()
        sprint.PrintTarget.CONSOLE = 1134