Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

Can't execute a simple psycopg2 script twice when running from ArcGIS Desktop as a script tool

$
0
0

I’m building a geoprocessing service that queries an SDE database (running on postgres) and returns results. I do a lot of development by calling the script from a toolbox in ArcGIS desktop 10.3.

For some reason when I call the script below in ArcGIS desktop, it executes successfully the first time, then fails every time after that with ‘NoneType’ object is not callable
on line 12 as I try to iterate over inAllCornerPointsList. If I close ArcMap and call it, it works the first time, then fails.

import psycopg2

conn = psycopg2.connect(host='localhost', database ='sde', user='sde', password='somepassword')
curs = conn.cursor()

sqlStatement = """SELECT * FROM sde.gly_ula_corners"""

curs.execute(sqlStatement)
inAllCornerPointsList = curs.fetchall()

for cornerPoint in inAllCornerPointsList:
    print cornerPoint

curs.close()
conn.close()

print 'Complete'

To further confuse things, if I select * from a different table (sde.countyboundaries), my script executes successfully every time.

The geometry type for sde.gly_ula_corners is shape st_point. The geometry type for sde.countyboundaries is shape st_geometry. This is the only difference that jumps out at me right away– one is a point fc, and one is a polygon.

Any idea what might be causing this? Is there some weird memory environment at work? Calling the script multiple times from the command line or pythonwin does not fail.


Viewing all articles
Browse latest Browse all 1138

Trending Articles