Esempio n. 1
0
def read_ddl_file_test():
    db = read_ddl_file()
    # print(db)
    for key, value in db.items():
        if key != 'sql':
            print("[{}] = {}".format(key, value))
        else:
            print("[{}]".format(key))
            for k, v in value.items():
                print("\t[{}]\n\t\t{}".format(k, v))
 def __create_database(self):
     try:
         sql = read_ddl_file()
         conn = ExplicitlyConnectionPool.get_instance().get_connection()
         cursor = conn.cursor()
         cursor.execute(
             "CREATE DATABASE {} DEFAULT CHARACTER SET 'utf8'".format(
                 self._db['database_name']))
         print("CREATE DATABASE {}".format(self._db['database_name']))
     except Error as err:
         if err.errno == errorcode.ER_DB_CREATE_EXISTS:
             cursor.execute("DROP DATABASE {} ".format(
                 self._db['database_name']))
             print("DROP DATABASE {}".format(self._db['database_name']))
             cursor.execute(
                 "CREATE DATABASE {} DEFAULT CHARACTER SET 'utf8'".format(
                     self._db['database_name']))
             print("CREATE DATABASE {}".format(self._db['database_name']))
         else:
             print(err.msg)
     finally:
         cursor.close()
         conn.close()
 def __init__(self):
     self._db = read_ddl_file()
 def __init__(self,
              source_dir='C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/',
              data_dir='data/'):
     self._db = read_ddl_file()
     self.source_dir = source_dir
     self.data_dir = data_dir