def create_db_sqlite(): global DB_SQLITE global DB_SQLITE_EXCEPTION try: DB_SQLITE = db.Database(type=db.SQLITE, name="pattern_unittest_db", host=HOST, port=PORT, username=USERNAME, password=PASSWORD) except Exception, e: DB_SQLITE_EXCEPTION = e
def create_db_mysql(): global DB_MYSQL global DB_MYSQL_EXCEPTION try: DB_MYSQL = db.Database(type=db.MYSQL, name="pattern_unittest_db", host=HOST, port=PORT, username=USERNAME, password=PASSWORD) except ImportError, e: DB_MYSQL_EXCEPTION = None # "No module named MySQLdb"
def create_db_sqlite(): global DB_SQLITE # Make sure the database handle is setup and connected if not DB_SQLITE or not DB_SQLITE._connection: DB_SQLITE = db.Database( type = db.SQLITE, name = "pattern_unittest_db", host = HOST, port = PORT, username = USERNAME, password = PASSWORD) # Drop all tables first for table in list(DB_SQLITE.tables): DB_SQLITE.drop(table) return DB_SQLITE