Insert in a Table with Array Columns
This code snippet will illustrate how to harness array support to efficiently manage collections of values within your database.
sql = "INSERT INTO tarry VALUES (
1,
array[-4367937811447089352, 7, 5575876413993699465],
array[0.023533916958532797, 5.476721734666199, 1.0],
array['MADRID','MURCIA','JEREZ'])"
try:
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
except Exception as e:
print("Error:", e)
finally:
cursor.close()