def main(): logger = logCreate.getLogger(__name__, logSettings.mycomponent['logger']) hostname = readValue('hostname', section='mysql') database = readValue('database', section='mysql') username = readValue('username', section='mysql') password = readValue('password', section='mysql') tablename = readValue('sqltablename', section='mysql') cur, cnx = sqlConnet(database, username, password, hostname, logger) logger = logCreate.getLogger(__name__, logSettings.mycomponent['logger']) updat = update_table(logger, cur, cnx, database, tablename, hostname, username, password)
def main(): logger =logCreate.getLogger(__name__,logSettings.mycomponent['logger']) hostname = readValue('hostname',section='mysql') database = readValue('database',section='mysql') username = readValue('username',section='mysql') password = readValue('password',section='mysql') tablename = readValue('sqltablename',section='mysql') cur,cnx = sqlConnet(database,username,password,hostname,logger) logger =logCreate.getLogger(__name__,logSettings.mycomponent['logger']) df_new_feat=pd.read_excel('../data/FeatureLevelsFinal.xlsx') predict=predict_data(logger,df_new_feat,cur,cnx,database,tablename,hostname,username,password)
def main(): logger = logCreate.getLogger(__name__, logSettings.mycomponent['logger']) hostname = readValue('hostname', section='mysql') database = readValue('database', section='mysql') username = readValue('username', section='mysql') password = readValue('password', section='mysql') tablename = readValue('sqltablename', section='mysql') flagdata = pd.read_excel("../data/FeatureLevelsFinal.xlsx") cur, cnx = sqlConnet(database, username, password, hostname, logger) safe_update1 = "set sql_safe_updates = 0;" safe_update2 = "set sql_safe_updates = 1;" try: cur.execute(safe_update1) sql1 = "ALTER TABLE {}.{} ADD Topic varchar(70);".format( database, tablename) cur.execute(sql1) cur.execute(safe_update1) sql2 = "ALTER TABLE {}.{} ADD SubTopic varchar(70);".format( database, tablename) cur.execute(sql2) cur.execute(safe_update1) except: pass predict = flagupdate(cur, cnx, database, tablename, flagdata)
def main(): logger = logCreate.getLogger(__name__, logSettings.mycomponent['logger']) hostname = readValue('hostname', section='mysql') database = readValue('database', section='mysql') username = readValue('username', section='mysql') password = readValue('password', section='mysql') tablename = readValue('sqltablename', section='mysql') cur, cnx = sqlConnet(database, username, password, hostname, logger) df = pd.read_excel('../data/dbbackup/appreviewsAnalysis.xlsx') query = 'select count(*) from %s.%s;' % (database, tablename) cur = cnx.cursor() cur.execute(query) n = cur.fetchone() db_cnt = n[0] csv_cnt = df.shape[0] if db_cnt < csv_cnt: print("loading csv data to database") df_to_mysql(tablename, cur, cnx, database, username, password, hostname, logger, df) else: print('already database has more records than csv')
#!/usr/bin/python3 # coding: utf-8 # packages import warnings warnings.filterwarnings("ignore") import configparser import logCreate import logSettings import pymysql from readConfig import readValue import sys log = logCreate.getLogger(__name__, logSettings.mycomponent['logger']) config = configparser.ConfigParser() config.read('../etc/application.ini') def db_connet(newdbname, newuser, newpassword, newhost): try: cnx = pymysql.connect(user=user, password=password, host=host, database=database) cur = cnx.cursor() return cur, cnx except: print( "updating the new username,password,host and database to application file" ) print("Please logout and execute setup.py again...")
def main(): logger = logCreate.getLogger(__name__, logSettings.mycomponent['logger']) data_master = pd.read_excel('../data/3_train_test.xlsx', index=None) train1 = train_data(logger, data_master)