AnsweredAssumed Answered

arcpy SQL expression for PostGIS

Question asked by StefanKaps on Apr 29, 2015
Latest reply on Apr 30, 2015 by bixb0012

I am developing a toolbox where the user can select an attribute (dropdown list) which comes from a PostGIS database and based on this attribute a select statement (selectbyAttribute) will be executed... Sounds easy...

 

Here is a code snippet:

 

     input_AZ = str(arcpy.GetParameterAsText(0))

     sql_exp =  'aktenzahl = '  + input_AZ                                    ("aktenzahl" is the column (character) of the PostGIS db)

     arcpy.SelectLayerByAttribute_management (lyr_postgis, "NEW_SELECTION", sql_exp)

 

 

sql_exp looks like this:

"aktenzahl = VIIa-20150429a"

 

but I get the following error:

ERROR 000358

[The SQL statement was not a select statement]

 

 

Does somebody know, how a SQL statement in arcpy has to look like (e.g. inverted comma) when executing on PostGIS?

 

Thank you in advance!

Stefan

 

 

Outcomes