# query parameters query_params = { 'DATA_PATH': DATA_PATH, 'QUERY_PATH': QUERIES_PATH, 'QUERY_FILE': 'experiment_results_vA.sql', 'QUERY_REPLACE': { '@DATE_FROM': '2021-11-05' } } def run_query_in_snowflake(query_params, cursor): ''' Load query file and run it on snowflake. ''' start_time = time.time() print(f"Running query {query_params['QUERY_FILE']}...") with open(query_params['QUERY_PATH'] + query_params['QUERY_FILE'], 'r') as file : query_string = file.read() for key, value in query_params['QUERY_REPLACE'].items(): query_string = query_string.replace(key, value) cursor.execute(query_string) df_ = cursor.fetch_pandas_all() print(f"Number of samples: {len(df_)}") print(f"Took {((time.time() - start_time)/60):.3f} minutes.") print("End.") return df_
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter