Пример #1
0
 def connection(self):
     try:
         return pyodbc.connect(driver=self.driver,
                               server=self.server,
                               database=self.database,
                               uid=self.uid,
                               pwd=self.pwd)
     except Exception as e:
         writeLog(e).write_log()
Пример #2
0
def get_urls_from_file(file_path=URLS):
    try:
        with open(file_path) as json_urls:
            urls = json.load(json_urls)
            urls['urls']
            return urls

    except Exception as e:
        writeLog(e).write_log()

    finally:
        json_urls.close()
Пример #3
0
def make_request_ga(urls, token):
    request_result = None

    try:
        for name in urls['urls']:
            for key, url in urls['urls'][name].items():
                request_result = requests.get(url + token)
                result_json = request_result.json()
                urls['urls'][name][key] = result_json['rows'][0][0]

        return urls

    except Exception as e:
        writeLog(e).write_log()
Пример #4
0
    def executeProc(self, procName, procParams):

        params = self.orderParamsToExecProc(procParams)

        try:
            con = self.connection()
            cursorTest = con.cursor()
            cursorTest.execute("EXEC "+ procName +" ?", [params])
            con.commit()
            
        except Exception as e:
            writeLog(e).write_log()
            print(e)

        finally:
            con.close()
Пример #5
0
def make_request_ga(urls, token):
    request_result = None

    try:
        for name in urls['urls']:
            for key, url in urls['urls'][name].items():
                request_result = requests.get(url + token)
                result_json = request_result.json()

                if 'rows' in result_json:
                    if len(result_json['rows']) == 1:
                        urls['urls'][name][key] = result_json['rows'][0][0]
                    else:
                        urls['urls'][name] = json_to_df(result_json, key)
                else:
                    urls['urls'][name][key] = '0'

        return urls

    except Exception as e:
        print(e)
        writeLog(e).write_log()
Пример #6
0
def get_access_token(scope=SCOPE, key_filepath=KEY_FILEPATH):
    try:
        return ServiceAccountCredentials.from_json_keyfile_name(
            key_filepath, scope).get_access_token().access_token
    except Exception as e:
        writeLog(e).write_log()