コード例 #1
0
ファイル: cubi_sql.py プロジェクト: jhanley412/cubi
    def __init__(self, server, database=None, table=None):
        self.server = server
        self.database = database
        self.table = table
        self.parameters_dictionary = {
            'Server': self.server,
            'Database': self.database,
            'TableName': self.table
        }

        #Logging initialization
        easylogging.setupLogging(logoutput_path=logdirectory)
        self.versatilelogger = logging.getLogger("versatile")
        self.errorlogger = logging.getLogger("error")
        self.consolelogger = logging.getLogger("consoleinfo")

        try:
            #Create connection to database
            connection = pymssql.connect(server=self.server)
            connection.close()

        #Catch and log any errors that cause program to fail
        except Exception as ex:
            self.errorlogger.exception(ex)
            self.versatilelogger.error(ex)
            self.consolelogger.error('Failed connection to server {0}'.format(
                self.server))
            raise
コード例 #2
0
ファイル: etl.py プロジェクト: jhanley412/cubi
    def __init__(
        self,
        wtserver,
        wtdatabase,
        wttable,
        filepath=None,
        filename=None,
        file_delimiter="\t",
        data_header_list=[],
        data_contents_dictionary={},
    ):
        self.wtserver = wtserver
        self.wtdatabase = wtdatabase
        self.wttable = wttable
        self.filepath = filepath
        self.filename = filename
        self.file_delimiter = file_delimiter
        self.data_header_list = data_header_list
        self.data_contents_dictionary = data_contents_dictionary

        easylogging.setupLogging(logoutput_path=logdirectory)  # __logs file will be located in Q:\Efficiency
        self.versatilelogger = logging.getLogger("versatile")
        self.errorlogger = logging.getLogger("error")
        self.consolelogger = logging.getLogger("consoleinfo")

        # Standard output for multiple data input options. Create etl header and contents for sql upload from either a file or data dictionary {R:{C:V}}
        self.header_list = []
        self.contents_dictionary = {}
        self.original_contents_dictionary = (
            {}
        )  # Used in excpetion report output. Unaltered, excepted items will write to csv file

        try:

            if len(self.data_header_list) != 0 and len(self.data_contents_dictionary) != 0:
                # ***Consider update. Data dictionary input is not refined. Assuming user input will enter 'Refined' data according to SQL standards.
                self.header_list = self.data_header_list  # [header.strip().title() for header in self.data_header_list]
                self.contents_dictionary = (
                    self.data_contents_dictionary
                )  # {str(header).strip().title():self.data_contents_dictionary[header] for header in self.data_contents_dictionary}
                self.original_contents_dictionary = (
                    self.data_contents_dictionary
                )  # {str(header).strip().title():self.data_contents_dictionary[header] for header in self.data_contents_dictionary}

            elif self.filepath != None and self.filename != None:
                file = Filer(self.filepath, self.filename)
                self.header_list = file.fileExtract(output="GetRefinedHeader", delimiter=file_delimiter)
                self.contents_dictionary = file.fileExtract(output="GetRefinedContents", delimiter=file_delimiter)
                self.original_contents_dictionary = file.fileExtract(
                    output="GetRefinedContents", delimiter=file_delimiter
                )

            else:
                self.versatilelogger.info("No input data defined")

        except Exception as ex:
            self.errorlogger.exception(ex)
            self.versatilelogger.error(ex)
            raise
コード例 #3
0
ファイル: dataanalysis.py プロジェクト: jhanley412/pycubi
    def __init__(self, dataheader=[], datacontents={}):
        self.datacontents = datacontents
        self.dataheader = dataheader

        easylogging.setupLogging(logoutput_path=logdirectory)
        self.versatilelogger = logging.getLogger("versatile")
        self.errorlogger = logging.getLogger("error")
        self.consolelogger = logging.getLogger("consoleinfo")
コード例 #4
0
ファイル: filer.py プロジェクト: jhanley412/cubi
    def __init__(self, filepath, filename):
        self.filepath = filepath
        self.filename = filename
        self.file = os.path.join(str(self.filepath), str(self.filename))

        easylogging.setupLogging(logoutput_path = logdirectory)
        self.versatilelogger = logging.getLogger("versatile")
        self.errorlogger = logging.getLogger("error")
        self.consolelogger = logging.getLogger("consoleinfo")
コード例 #5
0
    def __init__(self, filepath, filename):
        self.filepath = filepath
        self.filename = filename
        self.file = os.path.join(str(self.filepath), str(self.filename))

        easylogging.setupLogging(logoutput_path=logdirectory)
        self.versatilelogger = logging.getLogger("versatile")
        self.errorlogger = logging.getLogger("error")
        self.consolelogger = logging.getLogger("consoleinfo")
コード例 #6
0
ファイル: etl.py プロジェクト: jhanley412/cubi
    def __init__(self,
                 wtserver,
                 wtdatabase,
                 wttable,
                 filepath=None,
                 filename=None,
                 file_delimiter='\t',
                 data_header_list=[],
                 data_contents_dictionary={}):
        self.wtserver = wtserver
        self.wtdatabase = wtdatabase
        self.wttable = wttable
        self.filepath = filepath
        self.filename = filename
        self.file_delimiter = file_delimiter
        self.data_header_list = data_header_list
        self.data_contents_dictionary = data_contents_dictionary

        easylogging.setupLogging(
            logoutput_path=logdirectory
        )  #__logs file will be located in Q:\Efficiency
        self.versatilelogger = logging.getLogger("versatile")
        self.errorlogger = logging.getLogger("error")
        self.consolelogger = logging.getLogger("consoleinfo")

        # Standard output for multiple data input options. Create etl header and contents for sql upload from either a file or data dictionary {R:{C:V}}
        self.header_list = []
        self.contents_dictionary = {}
        self.original_contents_dictionary = {
        }  # Used in excpetion report output. Unaltered, excepted items will write to csv file

        try:

            if len(self.data_header_list) != 0 and len(
                    self.data_contents_dictionary) != 0:
                #***Consider update. Data dictionary input is not refined. Assuming user input will enter 'Refined' data according to SQL standards.
                self.header_list = self.data_header_list  #[header.strip().title() for header in self.data_header_list]
                self.contents_dictionary = self.data_contents_dictionary  #{str(header).strip().title():self.data_contents_dictionary[header] for header in self.data_contents_dictionary}
                self.original_contents_dictionary = self.data_contents_dictionary  #{str(header).strip().title():self.data_contents_dictionary[header] for header in self.data_contents_dictionary}

            elif self.filepath != None and self.filename != None:
                file = Filer(self.filepath, self.filename)
                self.header_list = file.fileExtract(output='GetRefinedHeader',
                                                    delimiter=file_delimiter)
                self.contents_dictionary = file.fileExtract(
                    output='GetRefinedContents', delimiter=file_delimiter)
                self.original_contents_dictionary = file.fileExtract(
                    output='GetRefinedContents', delimiter=file_delimiter)

            else:
                self.versatilelogger.info('No input data defined')

        except Exception as ex:
            self.errorlogger.exception(ex)
            self.versatilelogger.error(ex)
            raise
コード例 #7
0
ファイル: cubi_sql.py プロジェクト: jhanley412/cubi
 def __init__(self, server, database = None, table = None):
     self.server = server
     self.database = database
     self.table = table
     self.parameters_dictionary = {'Server':self.server, 'Database':self.database, 'TableName':self.table}
     
     #Logging initialization
     easylogging.setupLogging(logoutput_path = logdirectory)
     self.versatilelogger = logging.getLogger("versatile")
     self.errorlogger = logging.getLogger("error")
     self.consolelogger = logging.getLogger("consoleinfo")
     
     try:
         #Create connection to database
         connection = pymssql.connect(server= self.server)
         connection.close()
         
     #Catch and log any errors that cause program to fail
     except Exception as ex:
         self.errorlogger.exception(ex)
         self.versatilelogger.error(ex)
         self.consolelogger.error('Failed connection to server {0}'.format(self.server))
         raise