Example #1
0
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)
	field_query = "SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{0}' AND TABLE_NAME = '{1}'"
	user_tb_cursor.execute(field_query.format(selected_db_name, table_name))
	field_in_table = user_tb_cursor.fetchall()
	#make new controller
	controller.new(
		controller_file, 
		writer.pascal_casing(table_name), 
		table_comment,
		field_in_table)
	#make new model
	model.new(model_file,
	 	writer.pascal_casing(table_name),
	 	table_comment, 
	 	table_engine, 
	 	table_collation,
	 	field_in_table)
	counter_tables += 1
finish_time = datetime.datetime.now()
total_time = (finish_time - start_time).total_seconds()
print("================================================================================")
print("|| {0} tables processed in {1} seconds".format(counter_tables, total_time))
print("================================================================================")