It seems like arcpy can only work with connection files. This creates one of two problems:
- Deployment requires manual creation of connection files.
- We have to write a bunch of code to recreate the connection file on each run. (Creating it only the first time is not feasible since the connection information may change.)
As a software developer who does not have access to the production environment, I want to minimize manual steps in the deployment, and I want to keep my code simple. I also want this information to be very easy to change and not require opening up ArcMap (which would be manual), so I want to store it in a simple text config file and establish connections on the fly in my script.
Is there a way to create a connection to a database without creating a connection file? An "in memory only" connection (like is possible with pretty much any other database technology, even Oracle, or a number of other libraries, like GDAL)?
I'm using ArcGIS 10.2, and I will only be establishing query layers.
Answer
You could create temporary connection files through a combination of the tempfile
module in the Python standard library and the Create Database Connection Geoprocessing tool.
Your config file could be read in your script, used to make a temporary connection file, establish your Query Layers, and then delete the connection file.
No comments:
Post a Comment