I am able to insert polygon data manually into a postGres DB with one column having polygon datatype however, when I try to do the same dynamically it is not working.
This works.
cur.execute("INSERT into public.test(timestamp,poly) values (now(),'((2,2),(3,4),(3,6),(1,1))');")
This doesnt.
coords='((2,2),(3,4),(3,6),(1,1))'
cur = cnn.cursor()
cur.execute("INSERT into public.test(timestamp,poly) values (now(),'coords');")
so only difference is that , this time I am converting the same co ordinates into a tuple of tuples and passing that as a variable into the query.
Error: psycopg2.errors.InternalError_: parse error - invalid geometry
'
'
above declares a string in Python, but PostgreSQL needs a string that is wrapped in'
; trycoords = "'((2,2),(3,4),(3,6),(1,1))'"