I am new in Python. In my current python project I am constructing a SQL query string as follows:
sql = f'INSERT INTO my_table (col1, col2) VALUES'
val_str = ''
num_rows_updated_in_curr_batch = 0;
for param in params :
val_str += str(param) +',' ##params = [(v1, v2),(v3, v4)...]
num_rows_updated_in_curr_batch += 1
if num_rows_updated_in_curr_batch == 1000:
val_str = val_str.strip(',')
curr_sql_query = sql + val_str
val_str = ''
Basically in each batch, I want SQL query string as follows:
INSERT INTO my_table (col1, col2) VALUES (v1,v2),(v3,v4)
Please suggest if there is any better way to do this.