@@ -81,7 +81,7 @@ def _iter_receive_result(self, query, query_id=None, with_column_types=False):
8181 yield r
8282
8383 def execute (
84- self , query , params = None , with_column_types = False , query_id = None , settings = None
84+ self , query , params = None , with_column_types = False , query_id = None , settings = None
8585 ):
8686 """
8787 Executes query.
@@ -138,17 +138,20 @@ def _process_insert_query(self, query, params):
138138 if params is not None and len (params ) > 0 :
139139 if isinstance (params [0 ], tuple ):
140140 tuple_ls = params
141+ elif isinstance (params [0 ], dict ):
142+ # if params type is list[dictionary], then it's a insert query
143+ tuple_ls = [tuple (p .values ()) for p in params ]
141144 else :
142145 tuple_ls = [
143- tuple (params [i : i + batch_size ])
146+ tuple (params [i : i + batch_size ])
144147 for i in range (0 , len (params ), batch_size )
145148 ]
146149 insert_rows = len (tuple_ls )
147150 self ._uploader .upload_to_table_by_copy (table_name , tuple_ls )
148151 return insert_rows
149152
150153 def _process_ordinary_query (
151- self , query , params = None , with_column_types = False , query_id = None
154+ self , query , params = None , with_column_types = False , query_id = None
152155 ):
153156 if params is not None :
154157 query = self ._substitute_params (query , params , self .connection .context )
@@ -159,7 +162,7 @@ def _process_ordinary_query(
159162 )
160163
161164 def execute_iter (
162- self , query , params = None , with_column_types = False , query_id = None , settings = None
165+ self , query , params = None , with_column_types = False , query_id = None , settings = None
163166 ):
164167 if params is not None :
165168 query = self ._substitute_params (query , params , self .connection .context )
@@ -168,7 +171,7 @@ def execute_iter(
168171 )
169172
170173 def _iter_process_ordinary_query (
171- self , query , with_column_types = False , query_id = None
174+ self , query , with_column_types = False , query_id = None
172175 ):
173176 return self ._iter_receive_result (
174177 query , query_id = query_id , with_column_types = with_column_types
0 commit comments