I am trying to teach myself to access sql tables from an ArcPy script as part of a larger QC process. I am fairly certain that I have the sql statement correct (it works in SQL Server, albeit formatted a little differently), but I have no clue how to return my declared sql variable back as a python variable so that I may run other stuff on it.
I am trying to check a sql table in an ArcSDE Database where the value of a single column is smaller than 1000 and larger than 10. If there are values outside this range, I need to run other processes.
This is what I've got so far:
SDE = r'Database Connections\NC_RISK - 106.sde' SQLLink = arcpy.ArcSDESQLExecute(SDE) L_HAZARDPROBABILITY = r'\NC_RISK.sql.L_HAZARDPROBABILITY' sql = '''DECLARE @MyBadIndicator int; SET @MyBadIndicator = 0; SET @MyBadIndicator = SELECT 1 WHERE EXISTS (SELECT L_HAZARDPROBABILITY.F_EVENT FROM L_HAZARDPROBABILITY WHERE L_HAZARDPROBABILITY.F_EVENT<10 Or L_HAZARDPROBABILITY.F_EVENT >1000)'''
How do a get the value of MyBadIndicator so that ArcPy can use it?