I'm trying to find a way to access a feature class in an Oracle database through arcpy scripting, without having to be prompted to enter a user name and password after the script has started running. It seems like arcpy.management.CreateDatabaseConnectionString
can be a good way to do this. I'm testing it by establishing a connection that way, and then running Feature Class to Feature Class to make sure I can successfully access the data. The problem is, this works with one feature class, but doesn't work with a different feature class in the same database. I would like for it to work consistently. Here is the Python code I'm using:
import arcpy
import os
# get current user name
username = os.getenv('username')
userpw = "********"
# database connection string - for accessing a specific feature class
databasefc = arcpy.management.CreateDatabaseConnectionString("ORACLE", "DATABASE_NAME", "DATABASE_AUTH", username, userpw, "", "FC_NAME")
# Feature Class to Feature Class - for testing connection to FC established above
outpath = "C:/Projects/ExampleGDB.gdb"
outname = "TESTING_OUTPUT"
arcpy.conversion.FeatureClassToFeatureClass(databasefc,outpath,outname)
Is there a reason why this would work with some feature classes but not others?
When I say it doesn't work, it does produce an output, but the output is an empty feature class (it should be a direct copy of the input feature class).
The only differences in the properties of the two FCs are: The FC that did not work is a line FC, while the one that worked is a point FC (not sure why this would matter); and the line FC that did not work has the properties "COGO Enabled: No" and "Split Model: Update/Insert" while the point FC that worked does not have these properties.
I have ArcGIS Pro 3.3.1 installed. I'm running this script in VS Code. I have the python interpreter set to use Python 3.11.8 64-bit (from the ArcGIS Pro installation). I'm using Windows 10 Enterprise 64-bit.