Esempio n. 1
0
 def connect(self, sql_str, db_name, df_flag=True):
     '''sql_str: query text to be sent to db
     db_name: str of the database query is sent to
     df_flag: Boolean to return an pandas dataframe or not'''
     connector = dbconnect.DatabaseConnect(db_name)
     try:
         if df_flag == False:
             connector.query(sql_str, df_flag=False)
             alliDF = "'{}' successfully ran".format(sql_str)
         elif df_flag == True:
             alliDF = connector.query(sql_str, df_flag=True)
     finally:
         self.alertsound()
     return alliDF
Esempio n. 2
0
import pymysql
import pandas as pd
import sys
import configparser
import itertools
import numpy as np
from dbconnect import dbconnect

connector = dbconnect.DatabaseConnect('CHECK_CPAR2')

file1=open("C:/Work/risk_codes/cdpsfmt1.child.txt","r")
d1 = {}
for line in file1:
    x1      = line.split("=")
    key     = x1[0].strip("'\r")
    value   = x1[1].strip(';\n\r')
    d1[key] = value.strip("'")

fd=open("C:/Work/risk_codes/codes.txt","r")
codeSet = {}
i = 0
for line in fd:
    codeSet[i] = line.split()
    i += 1

file3=open("C:/Work/risk_codes/cdps_dadc.txt","r")
d4 = {}
for line in file3:
    x1      = line.split("=")
    key     = x1[0].strip("'\r")
    value   = x1[1].strip(';\n\r')