<?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: Write a point into a SDE database in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480761#M37612</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I said before use the env.workspace to go inside your db.&lt;/P&gt;&lt;P&gt;Then use arcpy.ListFeatureClasses()&lt;/P&gt;&lt;P&gt;to see a list of the features available. This will give you the correct spelling of the feature you are trying to update including all the extra bits that are part of a sde feature (database name etc)&lt;/P&gt;&lt;P&gt;Then you know what fc should be called.&lt;/P&gt;&lt;P&gt;Once that be is established, try reading it first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Nov 2014 12:34:41 GMT</pubDate>
    <dc:creator>NeilAyres</dc:creator>
    <dc:date>2014-11-06T12:34:41Z</dc:date>
    <item>
      <title>Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480754#M37605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm looking for a solution with which it is possible to add a point (x,y) into a SDE database.&lt;/P&gt;&lt;P&gt;I want to write a skript or add-in for it, so i prefer python (arcpy).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At first a need a way to connect to the database. Any ideas ?&lt;/P&gt;&lt;P&gt;I allready tried the insert cursor but this only works for a geodatabase not a SDE database.&lt;/P&gt;&lt;P&gt;I'm thankful for any help. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 07:52:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480754#M37605</guid>
      <dc:creator>ChristofLink</dc:creator>
      <dc:date>2014-11-05T07:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480755#M37606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Set up the connection file using the usual tools in ArcCatalog.&lt;/P&gt;&lt;P&gt;Then set a pointer to this in your python script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like :&lt;/P&gt;&lt;P&gt;ConnectFile = "Path &amp;amp; name of my connection file.sde"&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = ConnectFile&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you are in....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 08:06:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480755#M37606</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2014-11-05T08:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480756#M37607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your fast answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I set up the databaseconnection using ArcCatalog and found the connection file.&lt;/P&gt;&lt;P&gt;So this works thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But how can I access to different tables to add or read some data?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 09:38:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480756#M37607</guid>
      <dc:creator>ChristofLink</dc:creator>
      <dc:date>2014-11-05T09:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480757#M37608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Once you are in and have the correct permissions you can do anything. So be careful!&lt;/P&gt;&lt;P&gt;I normally do this in the Python ILDE, try -&lt;/P&gt;&lt;P&gt;arcpy.ListTables() or arcpy.ListFeatureClasses() for example.&lt;/P&gt;&lt;P&gt;There is plenty of code snippets in the help or on this site to get going with.&lt;/P&gt;&lt;P&gt;What are you trying to do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 10:17:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480757#M37608</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2014-11-05T10:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480758#M37609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok I try a little bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a shape file which contains points and I have to copie all of these into a given table of the sde database.&lt;/P&gt;&lt;P&gt;At this point in time I'm able to get alle points out of the shape file and now I try to get these in the database.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 10:44:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480758#M37609</guid>
      <dc:creator>ChristofLink</dc:creator>
      <dc:date>2014-11-05T10:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480759#M37610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you already have spatial data (shapefile) why don't you just import it into your db. Or use the copy features tool.&lt;/P&gt;&lt;P&gt;If you want to use scripting to create and write geometries check out:&lt;/P&gt;&lt;P&gt;CreateFeatureClasses :&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000002p000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000002p000000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;da Cursors :&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//002z0000001q000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//002z0000001q000000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Writing geometries :&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//002z0000001v000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//002z0000001v000000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;etc etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 05:55:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480759#M37610</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2014-11-06T05:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480760#M37611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No thats no so easy as it sounds. First of all I use a customize version of ArcGis and the hole process is more complex than described, because not all points has to write into the same table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I try to use the insert cursor but I have some problems with the path variables.&lt;/P&gt;&lt;P&gt;I want to access a feature class which is part of a diffrent dataset. So I tried this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fc = "connectionFile.sde\database.sde\dataset\featureclass"&lt;/P&gt;&lt;P&gt;icur = arcpy.da.insertCursor(fc, "SHAPE&lt;CODE&gt;&lt;SPAN class="str"&gt;@&lt;/SPAN&gt;&lt;/CODE&gt;")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this doesn't work. I got a error message "RuntimeError: cannot open 'connectionFile.sde\database.sde\datasete\featureclass'".&lt;/P&gt;&lt;P&gt;Is the path correct ? In another thread I read that I have to use points link this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fc = "connectionFile.sde\database.sde.dataset.featureclass"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this dosen't work either and I get the same error message.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 08:21:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480760#M37611</guid>
      <dc:creator>ChristofLink</dc:creator>
      <dc:date>2014-11-06T08:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480761#M37612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I said before use the env.workspace to go inside your db.&lt;/P&gt;&lt;P&gt;Then use arcpy.ListFeatureClasses()&lt;/P&gt;&lt;P&gt;to see a list of the features available. This will give you the correct spelling of the feature you are trying to update including all the extra bits that are part of a sde feature (database name etc)&lt;/P&gt;&lt;P&gt;Then you know what fc should be called.&lt;/P&gt;&lt;P&gt;Once that be is established, try reading it first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 12:34:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480761#M37612</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2014-11-06T12:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Write a point into a SDE database</title>
      <link>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480762#M37613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all verify the location and name of you sde (connection) file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Windows XP or Server 2003, navigate to Documents and Settings &amp;gt; &amp;lt;user_name&amp;gt; &amp;gt; Application Data &amp;gt; ESRI &amp;gt; Desktop&amp;lt;release#&amp;gt; &amp;gt; ArcCatalog.&lt;/P&gt;&lt;P&gt;On Windows Vista, 7, or Server 2008, navigate to Users &amp;gt; &amp;lt;user_name&amp;gt; &amp;gt; AppData &amp;gt; Roaming &amp;gt; ESRI &amp;gt; Desktop&amp;lt;release#&amp;gt; &amp;gt; ArcCatalog.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The file has an extension of .sde.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example I have one here:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14152785748529761" jivemacro_uid="_14152785748529761"&gt;
&lt;P&gt;conn = r"C:\Users\xbakker\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\NameOfMyConnectionFile.sde"&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To make use of the ListTables and ListFeatureClasses(), you will have to set your connection file to be the current workspace. You can do this like this:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14152785855206762" jivemacro_uid="_14152785855206762"&gt;
&lt;P&gt;arcpy.env.workspace = conn&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since featureclasses can reside in datasets you should list the available datasets first;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14152785935347409" jivemacro_uid="_14152785935347409"&gt;
&lt;P&gt;lst_fds = arcpy.ListDatasets()&lt;/P&gt;
&lt;P&gt;lst_fds.append("")&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second line is to append an empty string to the list of feature datasets, since featureclasses may reside outside a dataset. Next go through each dataset in the list and create for each dataset a list of featureclasses:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14152786000949411" jivemacro_uid="_14152786000949411"&gt;
&lt;P&gt;for fds in lst_fds:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses(feature_dataset=fds)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this list of featureclasses you can loop through each featureclass in that list and do something with it:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14152786067497317 jive_text_macro" jivemacro_uid="_14152786067497317"&gt;
&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the script to, in this case, print the names of all the featureclasses in the enterprise geodatabase would be:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14152786255241056" jivemacro_uid="_14152786255241056"&gt;
&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# name and location of your connection file&lt;/P&gt;
&lt;P&gt;conn = r"C:\Users\xbakker\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\NameOfYourConnectionFile.sde"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# set the current workspace&lt;/P&gt;
&lt;P&gt;arcpy.env.workspace = conn&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# create a list of feature datasets and append an empty string to the list&lt;/P&gt;
&lt;P&gt;lst_fds = arcpy.ListDatasets()&lt;/P&gt;
&lt;P&gt;lst_fds.append("")&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# loop through the list of feature datasets&lt;/P&gt;
&lt;P&gt;for fds in lst_fds:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # list the featureclasses in the current dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses(feature_dataset=fds)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # loop through each featureclass in the current dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # do somethig with the featureclass&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 12:57:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-a-point-into-a-sde-database/m-p/480762#M37613</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-11-06T12:57:47Z</dc:date>
    </item>
  </channel>
</rss>

