Based on the question "psycopg2: insert multiple rows with one query" (psycopg2: insert multiple rows with one query)
From JS, I receive the following on serverside: "2,3,4..."
Then, on server side(python 3.6):
list_urlquery = urlquery_partition.strip().split(",")
for i in range(len(list_urlquery)):
list_urlquery[i] = "(" + str(list_urlquery[i]).strip() + ", '" + str(
file.filename).strip() + "," + str(PATH_ID).strip() + "')"
insert_query = 'INSERT INTO tbl_ma (theid, thefilename, thepathid) VALUES %s'
psycopg2.extras.execute_values(cursor, insert_query, list_urlquery, template=None, page_size=100)
print (list_urlquery)
Output on Console: ["(2, 'Screenshot from 2018-05-29 07-13-47.png,1')", "(3, 'Screenshot from 2018-05-29 07-13-47.png,1')", "(4, 'Screenshot from 2018-05-29 07-13-47.png,1')"]
Error: INSERT has more expressions than target columns
I request you to guide me on this. How can I create a proper list/tuple and insert the data into database?