Example #1
0
print("================================================================================")
selected_db = input("Please, select the number of the db that you want to process: ")
print("================================================================================")
selected_db_name = database_list[selected_db][0]  #user selected database name
print("Selected database: {0}".format(selected_db_name))
user_db_access = Connect(host, username, password, selected_db_name)
user_db_connect = user_db_access.mysql()
#cursors
user_db_cursor = user_db_connect.cursor()
user_tb_cursor = user_db_connect.cursor()
#find all tables in the selected schema
user_db_query = "select TABLE_NAME, engine, TABLE_COLLATION, TABLE_COMMENT from information_schema.tables where table_schema='{0}'"
#make folder structure
writer = Writer(selected_db_name)
writer.make_base_dir()
writer.make_controller_dir()
writer.make_model_dir()
controller = Controller(selected_db_name)
model = Model(selected_db_name)
user_db_cursor.execute(user_db_query.format(selected_db_name))
start_time = datetime.datetime.now()
counter_tables = 1
for row in user_db_cursor.fetchall():
	#setting up all table variables
	table_name = row[0]
	table_engine = row[1]
	table_collation = row[2]
	table_comment = row[3]
	#creating new files
	controller_file = writer.make_controller_file(table_name)
	model_file = writer.make_model_file(table_name)