I want to do Query : SELECT ST_AsText(ST_MakePoint(-7.83753572095, 110.354612964)) ;
my python code =
import psycopg2
conn = psycopg2.connect(dbname = 'gis02', host= '127.0.0.1', user = 'gis2user',password= '123456')
cur = conn.cursor()
pointA={}
pointA['lat']=-7.83753572095
pointA['lon']=110.354612964
myquery = 'SELECT ST_AsText(ST_MakePoint(%s, %s)) ;'
pointA['geom']= cur.execute(myquery %(pointA['lat'], pointA['lon'])).fetchone()
The result is :
AttributeError: 'NoneType' object has no attribute 'fetchone'
when I do it directly in psql console I got :
POINT(-7.83753572095 110.354612964)
How to call Postgis's functions using psycopg2 ?