def save_databases(timestamp=None): #mycursor.execute('SHOW TABLES') #table_list = mycursor.fetchall() mydb, mycursor = myfct.connect() for table_name in table_list: query = 'SELECT * FROM '+table_name df = pandas.read_sql(query, con=mydb) df.to_csv(results_folder+'/'+table_name+'_'+str(timestamp)+'.csv') print('Databases saved') return
print('Database includes the following tables:') import mysql_functions mydb, mycursor = mysql_functions.connect() mycursor.execute('SHOW TABLES') tables = mycursor.fetchall() for x in tables: print(x[0]) mycursor.execute("SHOW columns FROM " + x[0]) print([column[0] for column in mycursor.fetchall()]) # for table_name in table_list: # print table_name # mycursor.execute("SHOW columns FROM "+table_name) # print [column[0] for column in mycursor.fetchall()] #df = mysql_functions.get_values('market_buses') #print df #df = mysql_functions.get_values('market_houses') #print df mycursor.execute("SHOW PROCESSLIST;")