4

I just upgraded to 10.3.1 and now I am having issues running my administrative tasks set with Python scripts.

I am unable to use the string "Database Connections/some.sde", i.e:

arcpy.ListUsers("Database Connections/some.sde) Returns the following error:

Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> userList = arcpy.ListUsers("Database Connections/some.sde") File "C:\Program Files\ArcGIS\Server\ArcPy\arcpy\__init__.py", line 1058, in ListUsers return utils.listofnamedtuples(gp.listUsers(sde_workspace), 'user') File "C:\Program Files\ArcGIS\Server\ArcPy\arcpy\geoprocessing\_base.py", line 504, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) TypeError: Could not open SDE workspace.

I can use the full path string for some tasks like ListUsers, AcceptConnections,etc., but not others like reconcile and post, e.g.:

"C:\Users\%username%\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\some.sde"

Fails without throwing error at: arcpy.ReconcileVersions_management("C:\Users\%username%\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\some.sde","ALL_VERSIONS","DBO.QC","DBO.Chris;DBO.Joe","LOCK_ACQUIRED","NO_ABORT","BY_OBJECT","FAVOR_EDIT_VERSION","POST","KEEP_VERSION","#")

The full script is here, which worked great prior to 10.3 upgrade: reconcile and post script

In ArcCatalog I have created these database connections, they work fine, I can browse in Catolog, and the .sde files exist in my AppData/Roaming/ESRI subdirectory. I have tried copying all my old connection strings from the 10.2 into my roaming profile. Is there some environmental variable that needs to be repaired? Do I need to re-install Server and Desktop on this machine?

Question: How can I repair my "Database Connections" to run Python scripts

7

Use full paths in scripts.

As far as python failing on opening the workspace, you may just be encountering a python format issue with the escape character. It is discussed on this nice blog

to illustrate:

>>> str = "C:\folder\file"
>>> str
'C:\x0colder\x0cile' <--Path being passed to arcpy (Bad)

>>> str = "C:\\folder\\file"
>>> str
'C:\\folder\\file'   <-- Good

>>> str = r"C:\folder\file"
>>> str
'C:\\folder\\file'   <-- Also Good
  • Good suggestions Ben, I have tried these though... I will post my temporary solution... Thanks – CCantey Jun 8 '15 at 13:36
5

I received help from ArcGIS tech support, my problem was that Arc Server is 64 bit and Desktop is 32 bit, and both products are installed so the most recent gets the default. Oops - I should have installed Server first.

Here is the tech article: FAQ: Why do Python scripts fail on a machine with both ArcGIS for Server and Desktop installed?

0

I have been using this script for more than a year... I am working with Arc tech support, they seem baffled as well.... So I got the script to work, but it requires what I consider 'hacks', the script should work as advertised in docs... I suspect there is something wrong with the environment I am working in.

The "Database Connections\some.sde" should work in Python scripts:

>>> arcpy.Exists('Database Connections\some.sde') True

(I can connect from a different non-administrative,machine off of our GIS Server to test this)

As for Python failing, I copied the python snippet from the reconcile tool and it contained the input parameter variables,such as "reconcile_mode="ALL_VERSIONS" rather than just passing in the parameter such as "ALL_VERSIONS", then the tool worked.... We shouldn't need to be explicit about this, but whatever for now...

arcpy.ReconcileVersions_management(input_database="C:\Users\ccantey\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\some.sde", reconcile_mode="ALL_VERSIONS", target_version="DBO.QC", edit_versions="DBO.Andrew;DBO.Chris;DBO.Joe;DBO.Kraig;DBO.Marc;DBO.Scott", acquire_locks="LOCK_ACQUIRED", abort_if_conflicts="NO_ABORT", conflict_definition="BY_OBJECT", conflict_resolution="FAVOR_EDIT_VERSION", with_post="POST", with_delete="KEEP_VERSION", out_log="")

  • I should note that it is only with arcpy.ReconcileVersions_management() that I have to explicitly state my input parameters, all my other methods seem to work normally - outside of the workspace string – CCantey Jun 8 '15 at 13:39
0

In my case, the ESRI representative technician reinstalled the portal due some problems, what fits with CCantey answer based on that tech article. Anyway, I'm not on the mood of reinstalling ArcGIS Desktop or search for another solution, so I present a not elegant solution:

Change the "Database Connections/some.sde" for 'C:\Users\your_user\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\some.sde\'.

Pay attention for your folder structure and ArcGIS version to make the necessary changes. In my case 'your_user' was the user who made ArcGIS Desktop installation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.