http://www.pygresql.org/ 下载
python setup.py build  #需要修改 指定 pg_config 文件路径
python setup.py install

@API http://www.pygresql.org/pg.html

import pgdb
db = pgdb.connect(user='postgres',database = 'postgres', host = '127.0.0.1',password='')
cur = db.cursor()
cur.execute("select  myname,AsText(pt) from test1 where ST_within( pt, 'POLYGON((0 0,0 70,100 70,100 0,0 0))' ) ;")
print cur.rowcount
cur.next()
# ['shanghai', 'POINT(31.5 60.87)']

import pgdb
db = pgdb.connect(user='postgres',database = 'postgres', host ='127.0.0.1',password='')
cur = db.cursor()
cur.execute('delete from test1;')
db.commit()




10-04 21:36