<?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: working around versioning with PYODBC? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520832#M17319</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Emeline!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the 'gisadmin' user the owner of the feature class?&amp;nbsp; If not, you will need to update the addsTable variable to include the feature class owner name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Aug 2014 16:36:03 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2014-08-19T16:36:03Z</dc:date>
    <item>
      <title>working around versioning with PYODBC?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520831#M17318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Has anyone else used pyodbc to work around versioning schema change limitations in SDE using Python?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://code.google.com/p/pyodbc/wiki/Cursor" title="https://code.google.com/p/pyodbc/wiki/Cursor"&gt;Cursor - pyodbc - Cursor API documentation - Python ODBC library - Google Project Hosting&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running into a wall when trying to concatenate the query to find the Add table that is related to a table in my SDE. Almost certain this doesn't have anything to do with Esri, but probably the module I am using. I posted the code on /r/python and /r/learnpython, but no responses so far, so figured this was worth a shot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can get the regID from the sde_table_registry and concatenate the adds table ('a123'). But when I use PYODBC syntax to check for the table, it says the table does not exist (which it &lt;EM&gt;DOES&lt;/EM&gt;). Even if I don't concatenate and just use the name of a table (in this example, LOCATIONS, commented out on line 34), it still says the table doesn't exist. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached the entire script. Here's the portion of the code that breaks (see &lt;STRONG&gt;Bold &lt;/STRONG&gt;line). Thanks in advanced for any help!:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Find Locations Add table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Checking for the Location Adds Table..."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; locTable = "LOCATIONS"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.execute('select registration_id from sde_table_registry where table_name = ?', (locTable,))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cursor.fetchone()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; regID = row[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print regID ##WORKS!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addsTable = "a" + str(regID)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print addsTable ##WORKS!&lt;/P&gt;&lt;P&gt;&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;&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; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Alter Locations Add table if it exists&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableChk = "table=" + addsTable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print tableChk ##WORKS!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #tableChk = "table='LOCATIONS'"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG&gt;&amp;nbsp; if cursor.tables(tableChk).fetchone():&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Altering the Locations Add table"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alterAddsTable = "'ALTER TABLE " + addsTable + " ALTER COLUMN [Comments] [nvarchar](255) NULL'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print alterAddsTable&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.execute(alterAddsTable)&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.commit()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Completed successfully"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Location Add table does not exist" ##&amp;lt;&amp;lt;&amp;lt; This is the response I get. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 15:22:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520831#M17318</guid>
      <dc:creator>emelinerenz1</dc:creator>
      <dc:date>2014-08-19T15:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: working around versioning with PYODBC?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520832#M17319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Emeline!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the 'gisadmin' user the owner of the feature class?&amp;nbsp; If not, you will need to update the addsTable variable to include the feature class owner name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 16:36:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520832#M17319</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-08-19T16:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: working around versioning with PYODBC?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520833#M17320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue here is more with the table "existing" than making the actual change. In the original script (not part of the one I posted here), I am able to use an ALTER statement to update the LOCATIONS table. But when I try to use the &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if cursor.tables(tableChk).fetchone():&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;syntax when &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;tableChk = "table='LOCATIONS'"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the script still tells me that the Table does not exist (basically that cursor.tables(tablechk).fetchone() = Nothing). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps! I know this isn't ArcPy, but if you have any other ideas, I'd love to hear them!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 16:54:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520833#M17320</guid>
      <dc:creator>emelinerenz1</dc:creator>
      <dc:date>2014-08-19T16:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: working around versioning with PYODBC?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520834#M17321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, in your script you are connecting to the database as the gisadmin user.&amp;nbsp; So, you are trying to query table 'gisadmin.a&amp;lt;registration id&amp;gt;'.&amp;nbsp; If gisadmin is not the owner of the table, then this table does not exist.&amp;nbsp; You will need to connect as the feature class owner, or update the variable to include the data owner.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 16:59:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520834#M17321</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-08-19T16:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: working around versioning with PYODBC?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520835#M17322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;GO TIT figured out!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DOESN'T WORK:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableChk = "table=" + addsTable&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&amp;nbsp; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&amp;nbsp; if cursor.tables(tableChk).fetchone():&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WORKS:&lt;/P&gt;&lt;P&gt;if cursor.tables(table=addsTable).fetchone():&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the input, though, Jake!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 17:36:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/working-around-versioning-with-pyodbc/m-p/520835#M17322</guid>
      <dc:creator>emelinerenz1</dc:creator>
      <dc:date>2014-08-19T17:36:57Z</dc:date>
    </item>
  </channel>
</rss>

