List feature classes can't find anything in SDE - why?

4842
11
11-13-2014 11:32 AM
AaronManuel
New Contributor III

I'm trying to create a script that pulls about 20 or so feature classes out of sde and puts them in a geodatabase for a group of people to look at for a special project. I'm trying to do this with a for loop and the copy_management function. However after playing around with the script for a while I realized I needed to start back at the beginning because I seem to be having an issue getting the ListFeatureClasses function to even return anything from my SDE connection. Here is just a simple test I put together:

import arcpy

import os

warehouse = r"C:\Users\aaronmanuel\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Warehouse.sde"

testgdb = r"C:\Projects\Test\TestGDB.gdb"

arcpy.env.workspace = warehouse

fcList = arcpy.ListFeatureClasses("*") 

print fcList

Running this script returns "[ ]" - an empty list.

Running it after changing the environment to the testgdb returns this:

[u'TestLine', u'coa_water_meter', u'coa_water_hydrant']

Which is correct, I put in these three features for testing purposes.

Googling has led me a few other threads of the "ListFeatureClasses returns an empty list" variety, but ultimately I couldn't find any real answer. What other factors besides stuff like typos and incorrect file paths could be causing this function to return and empty list?

Thanks.

0 Kudos
11 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Aaron,

Try replacing:

warehouse = r"C:\Users\aaronmanuel\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Warehouse.sde"

with:

warehouse = r"Database Connections\Warehouse.sde"

0 Kudos
AaronManuel
New Contributor III

Thanks for the suggestion Jake, but its still showing up empty.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Check the geodatabase connection properties.  Does the connecting user own data, or have read privileges to other feature classes?

0 Kudos
SusanJones
Occasional Contributor II

Check the properties of the sde connection file.

Have the credentials been saved?

Is it sql or windows authentication?

Check the process running the script has the correct permissions.

0 Kudos
IanMurray
Frequent Contributor

I'd do some debugging to check if you are actually connected to the sde with the path you gave it as the workspace or not.  You can use the workspace properties to check the connection string of the workspace and check the name of the server.  If you get blank strings, then there is a problem with your path to the sde, if not it could be that the feature classes in the sde are in feature datasets, not directly within the sde, so its returning no feature classes.

Help with Workspace Properties - ArcGIS Help 10.1

0 Kudos
AaronManuel
New Contributor III

I'm trying to run the code sample on the workspace properties help page now but I keep getting an error thrown at the first print statement that "method connectionString doesn't exist". I'm using python 2.6.5 with arcmap 10.0 .

I just copied the code and changed the Describe object path to my sde connection, am I doing something wrong?

0 Kudos
SusanJones
Occasional Contributor II

The AppData folder is hidden by default.

Go back and unhide it so arcpy can atleast see the sde connection file specified.

0 Kudos
AaronManuel
New Contributor III

thanks for the tip Susan, but even after unhiding the folder and all the subfolders/files I'm still getting the same "Connection String does not exist" error.

0 Kudos
SusanJones
Occasional Contributor II

Ok, how have you defined the connection string in the file?

The bit under "instance"

should be something like sde:sqlserver:[gisserver]

0 Kudos