AnsweredAssumed Answered

Arcpy.ListWorkspaces returns wrong results 

Question asked by ahmadabusaleh on Nov 22, 2017
Latest reply on Nov 28, 2017 by ahmadabusaleh

Hi, 

 

I am trying to get a list of database connections stored in the folder, the script runs successfully but it gives wrong results!

For example,  "inFolder=r'C:\1\test'"  has only one database connection which is u'C:\\1\\test\\Urbab.sde', but when I run the script it displays it 9 times every time! I tried to run the script from the python window in the ArcMap and I also used PyScripter and both of them gives the same result.

 

import arcpy, sys, os

inFolder=r'C:\1\test'
outFolder=r'C:\1\test2'
print "Connecting to geodatabase"
arcpy.env.workspace=inFolder
arcpy.env.overwriteOutput=True

for DBConn in inFolder:
       x=arcpy.ListWorkspaces("*","SDE")
       print x

 

What might be the issue here?

 

Thanks,

Ahmad

Outcomes