<?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: Access to Geodatabase table using python randomly denied. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179292#M64689</link>
    <description>&lt;P&gt;I would look in the Server Manager log to see if you can catch the error and hopefully see a better error message.&amp;nbsp; You may have to turn on more detailed log level.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jun 2022 01:08:27 GMT</pubDate>
    <dc:creator>DonMorrison1</dc:creator>
    <dc:date>2022-06-02T01:08:27Z</dc:date>
    <item>
      <title>Access to Geodatabase table using python randomly denied.</title>
      <link>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1178889#M64682</link>
      <description>&lt;P&gt;I have several scripts that are run against a geodatabase, each script creates a sde file with the credentials, then proceeds to read a value from a table using a search cursor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    database = gp.create_connectionfile(log, base_dir, user_do, instance_sde, "DATABASE_AUTH",
                                        username=user_do, password=password_do, save_user_pass="SAVE_USERNAME",
                                        database=database_name)
    arcpy.env.workspace = database

    # Retrieve and strip current version
    source_version = None
    with arcpy.da.SearchCursor("{0}.RAC_ADD_IN".format(user_do), "VERSION") as cursor:
        for row in cursor:
            if row[0]:
                source_version = StrictVersion(row[0].rsplit(".", 1)[0])
            break&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the set of scripts run, sometimes all scripts run without issue, sometimes one script fails, the issue is that the failing script is not always the same. the error presented is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt; ERROR cannot open 'DataOwner.RAC_ADD_IN'
 ERROR ['Traceback (most recent call last):\n', '  File "C:\\01_Script.py", line 134, in &amp;lt;module&amp;gt;\n    main(argv[1:])\n', '  File "C:\\01_Script.py", line 86, in main\n    with arcpy.da.SearchCursor("{0}.RAC_ADD_IN".format(user_do), "VERSION") as cursor:\n', "RuntimeError: cannot open 'DataOwner.RAC_ADD_IN'\n"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Facts:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The credential are always the same&lt;/LI&gt;&lt;LI&gt;The table is always the same&lt;/LI&gt;&lt;LI&gt;In the script above, the line 1 is just a wrapper to the arcpy function to create a sde connection file.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;This behavior has been appearing since ArcGIS Pro 2.8, currently this is running in 2.9.1&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How this can be managed?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 06:56:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1178889#M64682</guid>
      <dc:creator>Cristian_Galindo</dc:creator>
      <dc:date>2022-06-01T06:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Geodatabase table using python randomly denied.</title>
      <link>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179012#M64685</link>
      <description>&lt;P&gt;What is&amp;nbsp;gp.create_connectionfile()?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 15:18:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179012#M64685</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-06-01T15:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Geodatabase table using python randomly denied.</title>
      <link>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179292#M64689</link>
      <description>&lt;P&gt;I would look in the Server Manager log to see if you can catch the error and hopefully see a better error message.&amp;nbsp; You may have to turn on more detailed log level.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 01:08:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179292#M64689</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-06-02T01:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Geodatabase table using python randomly denied.</title>
      <link>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179336#M64690</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;As is is already state in the post:&amp;nbsp;&lt;/P&gt;&lt;P&gt;"In the script above, the line 1 is just a wrapper to the arcpy function to create a sde connection file. "&lt;/P&gt;&lt;P&gt;but for the sake of clarity, the implementation of the method is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def create_connectionfile(self, logger, out_folder_path, out_name, instance, account_authentication=None, username=None, password=None, save_user_pass=None,
                              database=None, schema=None, version_type=None, version=None, date=None):
        try:
            conn_file = "{0}.sde".format(os.path.join(out_folder_path, out_name))
            logger.add("Starting process to create connectionfile {0}".format(conn_file))
            if os.path.exists(conn_file):
                os.remove(conn_file)
                logger.add("Existing connectionfile {0} is removed".format(conn_file))

            arcpy.CreateDatabaseConnection_management(out_folder_path=out_folder_path,
                                                      out_name=out_name,
                                                      database_platform="SQL_Server",
                                                      instance=instance,
                                                      account_authentication=account_authentication,
                                                      username=username,
                                                      password=password,
                                                      save_user_pass=save_user_pass,
                                                      database=database,
                                                      schema=schema,
                                                      version_type=version_type,
                                                      version=version,
                                                      date=date)
            logger.add("Connection file {0} is created".format(conn_file))

            return conn_file
        except Exception as e:
            logger.add("Create_connection file has failed: {0}".format(e), "ERROR")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 06:09:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179336#M64690</guid>
      <dc:creator>Cristian_Galindo</dc:creator>
      <dc:date>2022-06-02T06:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Geodatabase table using python randomly denied.</title>
      <link>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179337#M64691</link>
      <description>&lt;P&gt;do you mean to change configuration for the logging process in the SQL server?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 06:17:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179337#M64691</guid>
      <dc:creator>Cristian_Galindo</dc:creator>
      <dc:date>2022-06-02T06:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Geodatabase table using python randomly denied.</title>
      <link>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179401#M64695</link>
      <description>&lt;P&gt;Sorry that was bad advice. I meant the ArcGIS Server Manager but that is irrelevant in your scenario.&amp;nbsp; Maybe you could add code to retry the connection a failed connection a number of times?&amp;nbsp; Is there something in your any of your scripts that would temporarily lock the database and prevent connections?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 11:45:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/access-to-geodatabase-table-using-python-randomly/m-p/1179401#M64695</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-06-02T11:45:57Z</dc:date>
    </item>
  </channel>
</rss>

