EDIT: When I try to access the workspace properties of the connection file, it says that the method workspaceType doesn't exist for describing data. When I use the regular 'Database Connections\myDB.sde' connection I can access the workspace properties just fine. When I run desc.dataType on it it comes back as "File"...how do I make it a workspace? The connection file is obviously not being treated as a workspace, and that's the first issue..
Using ArcGIS 10.5. SQL Server 2014, version 12.0.5207.0 (64 bit)
I am using the
CreateDatabaseConnection geoprocessing tool to create an SDE connection file and list feature classes within it. I am using this tool instead of the more typical
Database Connections\myDB.sde because I need to supply a username and password for connection by external users when this project is published up on a server and people run this script via a web interface. They won't have my windows authentication, thus the need for database authentication.
When using this script, I receive an exit code of 0 but it will not list the feature classes that I know exist in the database. I can see that it creates the SDE connection file. I have given the database user read and write membership using SQL Server Management Studio, so I'm not sure if it's a permissions issue.
import arcpy arcpy.CreateDatabaseConnection_management(out_folder_path='C:\Users\xxx\Desktop\GIS_Testing', out_name='HBM.sde', database_platform='SQL_SERVER', instance='sde:sqlserver:myServerName', account_authentication='DATABASE_AUTH', username='HBMWriter', password='xxx', save_user_pass='SAVE_USERNAME', database='HBMTest') arcpy.env.workspace = r'C:\Users\xxx\Desktop\GIS_Testing\HBMTest.sde' featClasses = arcpy.ListFeatureClasses() for fc in featClasses: print fc
It's worth noting that when I try to get some workspace properties on this SDE connection file, I get back: AttributeError: DescribeData: Method connectionProperties does not exist.
If I try to access connectionProperties of the regular
Database Connections\myDB.sde it'll give me the properties so it's as if it's not treating the connection file as a workspace.