2222query_ids = [id for id in data ['query_ids' ]]
2323
2424for id in query_ids :
25- try :
26- query = dune .get_query (id )
27- print ('PROCESSING: query {}, {}' .format (query .base .query_id , query .base .name ))
28-
29- # Check if query file exists in /queries folder
30- queries_path = os .path .join (os .path .dirname (__file__ ), '..' , 'queries' )
31- files = os .listdir (queries_path )
32- found_files = [file for file in files if str (id ) == file .split ('___' )[- 1 ].split ('.' )[0 ]]
33-
34- if len (found_files ) != 0 :
35- file_path = os .path .join (os .path .dirname (__file__ ), '..' , 'queries' , found_files [0 ])
36- # Read the content of the file
37- with open (file_path , 'r' , encoding = 'utf-8' ) as file :
38- text = file .read ()
39-
40- # Update existing file
41- dune .update_query (
42- query .base .query_id ,
43- query_sql = text ,
44- )
45- print ('SUCCESS: updated query {} to dune' .format (query .base .query_id ))
46- else :
47- print ('ERROR: file not found, query id {}' .format (query .base .query_id ))
48- except Exception as e :
49- print ('ERROR: {}' .format (str (e ))) #likely API permission errors
50- print ('Most errors are because your API key was not generated under the context of the query owner.' )
25+ query = dune .get_query (id )
26+ print ('PROCESSING: query {}, {}' .format (query .base .query_id , query .base .name ))
27+
28+ # Check if query file exists in /queries folder
29+ queries_path = os .path .join (os .path .dirname (__file__ ), '..' , 'queries' )
30+ files = os .listdir (queries_path )
31+ found_files = [file for file in files if str (id ) == file .split ('___' )[- 1 ].split ('.' )[0 ]]
32+
33+ if len (found_files ) != 0 :
34+ file_path = os .path .join (os .path .dirname (__file__ ), '..' , 'queries' , found_files [0 ])
35+ # Read the content of the file
36+ with open (file_path , 'r' , encoding = 'utf-8' ) as file :
37+ text = file .read ()
38+
39+ # Update existing file
40+ dune .update_query (
41+ query .base .query_id ,
42+ query_sql = text ,
43+ )
44+ print ('SUCCESS: updated query {} to dune' .format (query .base .query_id ))
45+ else :
46+ print ('ERROR: file not found, query id {}' .format (query .base .query_id ))
0 commit comments