<?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: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272384#M21041</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post the entire script?&amp;nbsp; It's tough to troubleshoot without knowing what the variables are.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Feb 2014 15:54:19 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2014-02-07T15:54:19Z</dc:date>
    <item>
      <title>SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock error</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272379#M21036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am attempting to run the following code (more or less, as I have simplified it for display here):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.env.workspace = ws
arcpy.env.overwriteOutput = True

arcpy.MakeFeatureLayer_management(sde_fc, gdb_fc)
arcpy.SelectLayerByLocation_management(gdb_fc, 'WITHIN_A_DISTANCE', gdb_asset_name, "1000")

matchcount = int(arcpy.GetCount_management(gdb_fc).getOutput(0))
if matchcount &amp;lt;&amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(gdb_fc, ws + "\\" + gdb_fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
arcpy.Near_analysis(gdb_fc, gdb_asset_name, "#", "#", "ANGLE")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It functions as expected when copying the selected features from a file geodatabase or shapefiles. However, when copying from SDE, it fails and returns:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000464: Cannot get exclusive schema lock.&amp;nbsp; Either being edited or in use by another application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lock request conflicts with an established lock&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To complicate matters, it isn't consistent with all SDE databases. On some it functions correctly, but not on the one I need to point to. Could this be a lock carrying over from SDE in the FGDB?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 14:02:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272379#M21036</guid>
      <dc:creator>MatthewBarlow</dc:creator>
      <dc:date>2014-02-07T14:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272380#M21037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Matt,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any ArcGIS Server services accessing the SDE feature classes?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, you can check the user that is causing the lock by making a connection to the geodatabase as an Administrator &amp;gt; right-click on the geodatabase &amp;gt; Administration &amp;gt; Administer Geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]31230[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 14:33:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272380#M21037</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-02-07T14:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272381#M21038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, the feature class from which the selection set is derived does have ArcGIS Server services pointed at it. I didn't think this would affect the features that are copied from SDE, however, once they are committed to the FGDB. The feature classes in the FGDB are where the Near_analysis is being run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've verified the user of the lock is the user that I am making the connection to SDE with. It is also the user that everyone in the organisation uses to access SDE (database authentication).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for your response,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Matt&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Matt,&lt;BR /&gt;&lt;BR /&gt;Do you have any ArcGIS Server services accessing the SDE feature classes?&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;Also, you can check the user that is causing the lock by making a connection to the geodatabase as an Administrator &amp;gt; right-click on the geodatabase &amp;gt; Administration &amp;gt; Administer Geodatabase.&lt;BR /&gt;&lt;BR /&gt;[ATTACH=CONFIG]31230[/ATTACH]&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 14:56:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272381#M21038</guid>
      <dc:creator>MatthewBarlow</dc:creator>
      <dc:date>2014-02-07T14:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272382#M21039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe the problem is when you run the Near analysis.&amp;nbsp; You are still running this on the SDE feature class.&amp;nbsp; Try the following instead:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.Near_analysis(&lt;STRONG&gt;ws + "\\" + gdb_fc&lt;/STRONG&gt;, gdb_asset_name, "#", "#", "ANGLE")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 15:28:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272382#M21039</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-02-07T15:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272383#M21040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have the selection/copy and Near_analysis in separate functions, so the below is my actual code for the Near_analysis bit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
new_asset = g_asset_name
ws = full_path + "\\" + g_gdb_name

arcpy.env.workspace = ws
arcpy.env.overwriteOutput = True
fcList = arcpy.ListFeatureClasses()
for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fc &amp;lt;&amp;gt; new_asset:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Near_analysis(fc, new_asset, "#", "#", "ANGLE")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does this look a bit better? My previous code example was pieced together, so apologies for the confusion. And many thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Matt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:18:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272383#M21040</guid>
      <dc:creator>MatthewBarlow</dc:creator>
      <dc:date>2021-12-11T13:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272384#M21041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post the entire script?&amp;nbsp; It's tough to troubleshoot without knowing what the variables are.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 15:54:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272384#M21041</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-02-07T15:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272385#M21042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The entire script is quite long and the variables are passed in from a wx dialog, so they aren't expressed in code... The strange behaviour is that the script functions correctly when pointed to a different SDE database or a FGDB that I created with manual exports from SDE. In these case, the Near_analysis performs as expected and populates a column with the angle &amp;amp; distance, which I turn into direction and distance. It is only when pointed at a specific SDE database that it encounters the schema lock. Very frustrating.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 17:31:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272385#M21042</guid>
      <dc:creator>MatthewBarlow</dc:creator>
      <dc:date>2014-02-07T17:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272386#M21043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think what Jake might be getting at is perhaps you are accessing the output FGDB workspace at the same time somewhere else in your code or not releasing a previous reference to it.&amp;nbsp; I'd think that would cause accessibility issues on subsequent attempts to write to the workspace.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 17:40:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272386#M21043</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-02-07T17:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: SDE copy feature to FGDB, subsequent Near tool execution fails with schema lock e</title>
      <link>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272387#M21044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I think what Jake might be getting at is perhaps you are accessing the output FGDB workspace at the same time somewhere else in your code or not releasing a previous reference to it.&amp;nbsp; I'd think that would cause accessibility issues on subsequent attempts to write to the workspace.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply. However, if I simply change my input source (which is a parameter in an input file) to a different SDE database that has a copy of the data OR an independent FGDB into which I copied the layers I need to access, it works fine. For example, I exported all 54 layers from this particular SDE database to another SDE database, pointed my script at that and it works fine. If my code is locking the FGDB I am writing to, then wouldn't it fail no matter the input source? Besides, my understanding is that it won't lock out subsequent processes within the same instance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 17:53:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sde-copy-feature-to-fgdb-subsequent-near-tool/m-p/272387#M21044</guid>
      <dc:creator>MatthewBarlow</dc:creator>
      <dc:date>2014-02-07T17:53:43Z</dc:date>
    </item>
  </channel>
</rss>

