<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CreateDatabaseConnection odd behavior in 10.1 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133103#M10359</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In case this clarifies things further, here is the workflow that I'm trying to model:&lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;User starts ArcMap and wants to connect to a database the first time (their AD account already has permissions to the DB, but they may not yet own a version to use for editing)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;A temporary connection is created with the default transactional version (sde.DEFAULT)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Call arcpy.ListVersions() on the temporary connection to see if the user already has a version; if not, use arcpy.CreateVersion_management() to create a private version with the user as the owner (ensures users can only edit under their version)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Remove the temporary connection and create a final connection using the version owned by the user (so far I haven't seen any way to simply modify the existing connection with a script)&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;BR /&gt;&lt;SPAN&gt;I cannot script all four steps because as I mentioned in previous post, arcpy.CreateDatabaseConnection_management() seems ignores the version parameter (at least in the case of SQL Server using OS Authentication). If I script the first three steps, and then manually use the Create Database Connection tool from the ArcCatalog toolbox, the version will be set appropriately. That led me to attempt to build a model linking a script which does the first three steps with the tool that does the 4th step. That fails, however, because if the user doesn't already have a version in the database then the model won't run... I get "ERROR 000800: The value is not a member of sde.DEFAULT | DBO.parent" which is thrown by the Create Database Connection tool, even though I have the output from my script (which creates the version using a temporary connection) set as a precondition to running the Create Database Connection tool in the model. Using variables as input to the Create Database Connection tool doesn't seem to work well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know of a way to successfully automate this workflow? Has anyone had any success in 10.1 with getting arcpy.CreateDatabaseConnection_management() to recognize the version parameter under SQL Server with OS Authentication? Can someone from ESRI please verify that this is indeed a bug with arcpy.CreateDatabaseConnection_management()?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Sep 2012 15:30:58 GMT</pubDate>
    <dc:creator>JasonKnisley</dc:creator>
    <dc:date>2012-09-20T15:30:58Z</dc:date>
    <item>
      <title>CreateDatabaseConnection odd behavior in 10.1</title>
      <link>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133102#M10358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a Python script that which creates a database connection using arcpy.CreateDatabaseConnection_management(), and while the connection is created it ignores the version that is passed in as a parameter. The version is valid and the function does not return an error. In order to verify that the parameters were being passed appropriately, I even went so far as to edit the method management.py to print the parameters immediately before it calls:&lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;retval = convertArcObjectToPythonObject(gp.CreateDatabaseConnection_management(*gp_fixargs((out_folder_path, out_name, database_platform, instance, account_authentication, username, password, save_user_pass, database, schema, version_type, version, date), True)))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my code, I call:&lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;arcpy.CreateDatabaseConnection_management(folderName, fileName, "SQL_SERVER", instance, "OPERATING_SYSTEM_AUTH", None, None, "SAVE_USERNAME", dbName, None, "TRANSACTIONAL", "DBO.test", None)

print "Version now set to " + arcpy.Describe(folderName + "/" + fileName).connectionProperties.version&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the attached screenshot the variables have been printed out in management.py immediately before creating the connection.&amp;nbsp; Afterwards, you can see that while the version should be "DBO.test" it is instead "sde.DEFAULT".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I use Python to create a SQL Server database connection using Operating System authentication with a transactional version name?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Sep 2012 18:37:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133102#M10358</guid>
      <dc:creator>JasonKnisley</dc:creator>
      <dc:date>2012-09-19T18:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: CreateDatabaseConnection odd behavior in 10.1</title>
      <link>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133103#M10359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In case this clarifies things further, here is the workflow that I'm trying to model:&lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;User starts ArcMap and wants to connect to a database the first time (their AD account already has permissions to the DB, but they may not yet own a version to use for editing)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;A temporary connection is created with the default transactional version (sde.DEFAULT)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Call arcpy.ListVersions() on the temporary connection to see if the user already has a version; if not, use arcpy.CreateVersion_management() to create a private version with the user as the owner (ensures users can only edit under their version)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Remove the temporary connection and create a final connection using the version owned by the user (so far I haven't seen any way to simply modify the existing connection with a script)&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;BR /&gt;&lt;SPAN&gt;I cannot script all four steps because as I mentioned in previous post, arcpy.CreateDatabaseConnection_management() seems ignores the version parameter (at least in the case of SQL Server using OS Authentication). If I script the first three steps, and then manually use the Create Database Connection tool from the ArcCatalog toolbox, the version will be set appropriately. That led me to attempt to build a model linking a script which does the first three steps with the tool that does the 4th step. That fails, however, because if the user doesn't already have a version in the database then the model won't run... I get "ERROR 000800: The value is not a member of sde.DEFAULT | DBO.parent" which is thrown by the Create Database Connection tool, even though I have the output from my script (which creates the version using a temporary connection) set as a precondition to running the Create Database Connection tool in the model. Using variables as input to the Create Database Connection tool doesn't seem to work well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know of a way to successfully automate this workflow? Has anyone had any success in 10.1 with getting arcpy.CreateDatabaseConnection_management() to recognize the version parameter under SQL Server with OS Authentication? Can someone from ESRI please verify that this is indeed a bug with arcpy.CreateDatabaseConnection_management()?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 15:30:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133103#M10359</guid>
      <dc:creator>JasonKnisley</dc:creator>
      <dc:date>2012-09-20T15:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: CreateDatabaseConnection odd behavior in 10.1</title>
      <link>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133104#M10360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jason, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately this is a bug with the CreateDatabaseConnection the bug number is NIM083195. For the time being you have three options. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. You can use the CreateArcSDEConnectionFile gp tool to create the connection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. After creating the connection you can edit it using ArcCatalog or the Catalog window in ArcMap to make it point to the new version.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Run the tool from ArcMap or ArcCatalog, the issue is only reproducible using Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note, if you want to make a direct connection using the first option, you can use the direct connect syntax outlined here in the 10.0 help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Making_a_direct_connection_from_ArcGIS_Desktop_to_a_geodatabase_in_SQL_Server/002q00000039000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Making_a_direct_connection_from_ArcGIS_Desktop_to_a_geodatabase_in_SQL_Server/002q00000039000000/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 15:43:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133104#M10360</guid>
      <dc:creator>RussellBrennan</dc:creator>
      <dc:date>2012-09-20T15:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: CreateDatabaseConnection odd behavior in 10.1</title>
      <link>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133105#M10361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a time frame on a fix for this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Apr 2013 21:08:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133105#M10361</guid>
      <dc:creator>RyanNelson2</dc:creator>
      <dc:date>2013-04-17T21:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: CreateDatabaseConnection odd behavior in 10.1</title>
      <link>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133106#M10362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a time frame on a fix for this?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now for the bad news.&amp;nbsp; This bug is fixed at 10.2 &lt;/SPAN&gt;&lt;A href="http://support.esri.com/en/bugs/nimbus/TklNMDgzMTk1"&gt;http://support.esri.com/en/bugs/nimbus/TklNMDgzMTk1&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;Over on the Desktop forum an ESRI employee wrote that SP2 for 10.1 turned into version 10.2.&amp;nbsp; So don't look for any fixes to 10.1.&amp;nbsp; I hope I'm wrong!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Apr 2013 21:46:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133106#M10362</guid>
      <dc:creator>RandyKreuziger</dc:creator>
      <dc:date>2013-04-17T21:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: CreateDatabaseConnection odd behavior in 10.1</title>
      <link>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133107#M10363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To solve this problem in version 10.1, this may be the alternative:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perform ArcObject code called for the creation of the connection file&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Install comtypes library from &lt;/SPAN&gt;&lt;A href="http://sourceforge.net/projects/comtypes/"&gt;http://sourceforge.net/projects/comtypes/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Enable Python to use ArcObjects&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When working to get ArcObjects and Python working together in version 10.1, you'll also need to make some modifications to your comtypes installation. The full solution is abbreviated here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A. Navigate to your comtypes directory&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (ex. C:\Python\ArcGIS10.1\Lib\site-packages\comtypes)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;B. Delete&amp;nbsp; the following&amp;nbsp; files (note that the �??safearray�?� files are not preceded by an underscore):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; automation.pyc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; automation.pyo&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; safearray.pyc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; safearray.pyo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;C. Open automation.py with a text editor and go to line 794 which is part of the �??ctype_to_vartype�?� dictionary. Add this line (including the comma):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VT_BYREF|VT_BSTR,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;D. Delete everything from the �??gen�?� directory.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;E. Copy Snippets.py (module developed by Mark Cederholm) to C:\Python[version]\ArcGIS[version]\Lib&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: Taken from &lt;/SPAN&gt;&lt;A href="http://www.sspinnovations.com/blog/2014/02/04/useful-scripts-non-programmer-converting-vba-scripts-python"&gt;http://www.sspinnovations.com/blog/2014/02/04/useful-scripts-non-programmer-converting-vba-scripts-python&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Implementing the Python code with the call&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attachements:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Snippets.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcObjects.py (CreateConnectionFile Phyton Implementation)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 15:22:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133107#M10363</guid>
      <dc:creator>Edwin</dc:creator>
      <dc:date>2014-02-18T15:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: CreateDatabaseConnection odd behavior in 10.1</title>
      <link>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133108#M10364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was trying to create Database User through Python but still encountered this problem. My ArcGIS for Desktop is 10.2.0.3348.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 08:20:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/createdatabaseconnection-odd-behavior-in-10-1/m-p/133108#M10364</guid>
      <dc:creator>VehaLa</dc:creator>
      <dc:date>2015-05-11T08:20:25Z</dc:date>
    </item>
  </channel>
</rss>

