I've been banging my head against this for a while, and am seeking some insight into what I'm doing wrong. I have the following snippet of code:
params = [PlaneRep.hex, PlaneRep.squawk, PlaneRep.flight, PlaneRep.isMetric, PlaneRep.mlat, PlaneRep.altitude, PlaneRep.speed, PlaneRep.vert_rate, dbdate, dbtime, PlaneRep.track, coordinates, PlaneRep.messages]sql = ''' INSERT into planereports (hex, squawk, flight, "isMetric", "isMLAT", altitude, speed, vert_rate, date_of_report, time_of_report, bearing, report_location, messages_sent) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, ST_PointFromText(%s, 4326), %s);'''print(cur.mogrify(sql, params))cur.execute(sql,params)which yields the following error:
b'\n\t\tINSERT into planereports (hex, squawk, flight, "isMetric", "isMLAT", altitude, speed, vert_rate, date_of_report, time_of_report, bearing, report_location, messages_sent)\n\t\tVALUES (\'7c6d33\', \'3241\', \'VOZ850 \', true, false, 9563, 822, 546.2016, \'2015-10-21\', \'04:32:41\', 235, ST_PointFromText(\'POINT(150.464266 -34.754929)\', 4326), 133);'Traceback (most recent call last)File "./jsonfiddling.py", line 92, in logToDB(dbconn, plane) File "./jsonfiddling.py", line 34, in logToDB cur.execute(sql,params) psycopg2.ProgrammingError: function st_pointfromtext(unknown, integer) does not existLINE 3: ...63, 822, 546.2016, '2015-10-21', '04:32:41', 235, ST_PointFr... ^HINT: No function matches the given name and argument types. You might need to add explicit type casts.Any ideas of what I'm doing wrong?
أكثر...
params = [PlaneRep.hex, PlaneRep.squawk, PlaneRep.flight, PlaneRep.isMetric, PlaneRep.mlat, PlaneRep.altitude, PlaneRep.speed, PlaneRep.vert_rate, dbdate, dbtime, PlaneRep.track, coordinates, PlaneRep.messages]sql = ''' INSERT into planereports (hex, squawk, flight, "isMetric", "isMLAT", altitude, speed, vert_rate, date_of_report, time_of_report, bearing, report_location, messages_sent) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, ST_PointFromText(%s, 4326), %s);'''print(cur.mogrify(sql, params))cur.execute(sql,params)which yields the following error:
b'\n\t\tINSERT into planereports (hex, squawk, flight, "isMetric", "isMLAT", altitude, speed, vert_rate, date_of_report, time_of_report, bearing, report_location, messages_sent)\n\t\tVALUES (\'7c6d33\', \'3241\', \'VOZ850 \', true, false, 9563, 822, 546.2016, \'2015-10-21\', \'04:32:41\', 235, ST_PointFromText(\'POINT(150.464266 -34.754929)\', 4326), 133);'Traceback (most recent call last)File "./jsonfiddling.py", line 92, in logToDB(dbconn, plane) File "./jsonfiddling.py", line 34, in logToDB cur.execute(sql,params) psycopg2.ProgrammingError: function st_pointfromtext(unknown, integer) does not existLINE 3: ...63, 822, 546.2016, '2015-10-21', '04:32:41', 235, ST_PointFr... ^HINT: No function matches the given name and argument types. You might need to add explicit type casts.Any ideas of what I'm doing wrong?
أكثر...