My code executes a simple SQL query to convert some WKB geometry to WKT. I get my WKB geometry from an url request. The code looks like this:
url = 'http://..........'
response = urllib2.urlopen(url).read()
responseJson = json.loads(response)
coordWKB = responseJson['wkb_geometry']
print(coordWKB)
cur.execute("SELECT ST_AsText(" + coordWKB + ")")
coordWKB
looks like this:
'0106000020E6100000010000000103000000010000001200000017A84D0F39925EC083FC69A455C342400A1451BC48925EC0422CDC116B........'
But I get the following error:
psycopg2.ProgrammingError: syntax error at or near "A84D0F39925EC083FC69A455C342400A1451BC48925EC0422CDC11................
LINE 1: ...000020E6100000010000000103000000010000001200000017A84D0F3992...
If I execute the code below it works:
cur.execute("select ST_AsText('0106000020E6100000010000000103000000010000001200000017A84D0F39925EC08.............')")
I can't seem to figure out what's wrong with the WKB I'm passing the query.