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.

  • Uh-oh. You really ought to go back and rebuild that geodatabase using best practice: The database should not be named 'sde'. No spatial table should ever be loaded as the 'sde' user (it should be reserved for administration; instead, create a login/user/schema to own the data). Please update the question to specify the geometry storage type -- if it's SDE.ST_GEOMETRY, then geometry column is opaque to the client. You should also focus on the differences between the working and non-working table(s). – Vince Jan 5 '16 at 2:15
  • Thanks for your comments. I'll talk to our dba about creating a new schema for these tables. I've updated the question to address possible differences between the tables-- do you think this might be causing it? – Charlie Hofmann Jan 5 '16 at 13:35
  • Please clarify that the ST_POINT is PostGIS. And yes, it seems that is the difference. It's also confusing to focus on Desktop and ArcSDE, since you don't appear to be using them -- This is a straight Python issue, and doesn't pertain to geoprocessing at all. – Vince Jan 5 '16 at 13:48
  • Thanks for your help. I don't have much experience with PostGIS, so apologies if this takes longer than it should. The database is postgres, and does (I believe) have PostGIS installed. How would I confirm that ST_Point is PostGIS? – Charlie Hofmann Jan 5 '16 at 13:52
  • The reason that I tagged this as geoprocessing and Desktop is that I only experience this in Desktop-- I can run this script from the commandline (pure python) successfully each time. It's only when called as a geoprocessing tool in Desktop that I experience these errors. – Charlie Hofmann Jan 5 '16 at 13:54
0

Turns out the issue was with decimal conversion. I converted my database fields to text based on this answer:

ArcGIS Geoprocessing "None Type" Second time

And then re-cast to float in my script. Now it works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.