AttributeError: ArcSDESQLExecute:

1442
2
Jump to solution
12-29-2020 06:10 AM
CliveSwan
Frequent Contributor

Greetings,

I am working in a locked down environment where I can't install any Python modules, so I have to rely on arcpy while working with SDE PostgresSQL.

I don't get any error message connecting, it doesn't return an error for the list of tables, only returns the wildcard, not the tables.

 

for tbl in tables:
      print(tbl)

## Only returns a single wildcard, not a list of tables

 

 

I get a DBMS error "-37 DBMS Table not found" when doing select or count..

 

import os, sys
import arcpy
import arcgis

arcpy.env.workspace = r"D:\Users\user\Documents\ArcGIS\Projects\Databases\Databases.gdb"
sdeconn = arcpy.ArcSDESQLExecute(r"Z:\a - Connection Files\gisserver_branch.sde")

tables = ["%"]

## Logged IN
print("Logged IN")

for tbl in tables:
    print(tbl)
                                                             
sql = "select objectid from PRP_LandParcels_Ply"

sdeconn_tables=sdeconn.execute(sql)

 

 

Appreciate any pointers, to get this working.

Regards,

Clive

1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

I'm not to sure on arcpy.ArcSDESQLExecute, but you've created a list called 'tables' which has one string in it "%" - iterating over this will return a single %, it makes little sense.

 

You may have to find the tables intially using the sde connection and  ListTables—ArcGIS Pro | Documentation

import arcpy

# Set the current workspace
arcpy.env.workspace = sde_connection

# Get and print a list of tables
tables = arcpy.ListTables()
for table in tables:
    print(table)

'tables' will be what you use to iterate over.

You also need a result of executing each query, sdeconn_tables=sdeconn.execute(sql) excutes the query, but what do you want to do with the result object contained in it? I'd advise just a print statement until you get it working.

Also if you could explain what you're actually trying to achieve, someone much more informed than me could probably help you better.

View solution in original post

2 Replies
DavidPike
MVP Frequent Contributor

I'm not to sure on arcpy.ArcSDESQLExecute, but you've created a list called 'tables' which has one string in it "%" - iterating over this will return a single %, it makes little sense.

 

You may have to find the tables intially using the sde connection and  ListTables—ArcGIS Pro | Documentation

import arcpy

# Set the current workspace
arcpy.env.workspace = sde_connection

# Get and print a list of tables
tables = arcpy.ListTables()
for table in tables:
    print(table)

'tables' will be what you use to iterate over.

You also need a result of executing each query, sdeconn_tables=sdeconn.execute(sql) excutes the query, but what do you want to do with the result object contained in it? I'd advise just a print statement until you get it working.

Also if you could explain what you're actually trying to achieve, someone much more informed than me could probably help you better.

BlakeTerhune
MVP Regular Contributor

To start simple, ensure the user defined in the gisserver_branch.sde connection has SELECT privileges on the PRP_LandParcels_Ply table. Second, is the table in a different schema (owner) than the user connecting? You may need to specify the schema with the table name in the sql. Like schemaName.PRP_LandParcels_Ply