<?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: SQL error when using Python call argument in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460160#M36038</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks. Works well.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Mar 2013 00:21:48 GMT</pubDate>
    <dc:creator>BobMCkay</dc:creator>
    <dc:date>2013-03-08T00:21:48Z</dc:date>
    <item>
      <title>SQL error when using Python call argument</title>
      <link>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460157#M36035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following code add two arguments to the Python call. The first argument works fine but the second gives an invalid SQL error when using SELECT. The script I have attached shows the parcel string hard coded to a Parcels variable, this works OK. Can someone provide the correct string for strParcels? Note the \\ is meant to relate to a \ in the final SQL&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; strOwner = "Lett"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; strParcels = "PARCEL_SPI = '1\\TP8994'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;retVal = Shell("cmd.exe /K S:\MID_Owners_Database_Workspace\OwnerProperty.py " &amp;amp; strOwner &amp;amp; " " &amp;amp; strParcels, 1)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Mar 2013 21:01:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460157#M36035</guid>
      <dc:creator>BobMCkay</dc:creator>
      <dc:date>2013-03-07T21:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL error when using Python call argument</title>
      <link>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460158#M36036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;The following code add two arguments to the Python call. The first argument works fine but the second gives an invalid SQL error when using SELECT. The script I have attached shows the parcel string hard coded to a Parcels variable, this works OK. Can someone provide the correct string for strParcels? Note the \\ is meant to relate to a \ in the final SQL&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;strOwner = "Lett" strParcels = "PARCEL_SPI = '1\\TP8994'" retVal = Shell("cmd.exe /K S:\MID_Owners_Database_Workspace\OwnerProperty.py " &amp;amp; strOwner &amp;amp; " " &amp;amp; strParcels, 1)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wow, that's a tricky one because you need to pass your string arguments through VBScript/VB/VBA (whatever that is), Windows shell, and Python to your tool!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my guess at it. I used literal double-quotes (""") to make sure arguments get passed to thru the Windows shell command line. I don't think you need to escape the "\" in your SQL expression because it will be read as a literal string before the Python interpreter gets a hold of it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;strOwner = """Lett""" strParcels = """PARCEL_SPI = '1\TP8994'""" retVal = Shell("cmd.exe /K " &amp;amp; _ &amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\Python27\ArcGIS10.1\python.exe " &amp;amp;_ &amp;nbsp;&amp;nbsp;&amp;nbsp; "S:\MID_Owners_Database_Workspace\OwnerProperty.py " &amp;amp;_ &amp;nbsp;&amp;nbsp;&amp;nbsp; strOwner &amp;amp; " " &amp;amp; strParcels, _ &amp;nbsp;&amp;nbsp;&amp;nbsp; 1)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is as if you typed the command line (probably a good way to test it):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;C:\&amp;gt; cmd.exe /K C:\Python27\ArcGIS10.1\python.exe ^ S:\MID_Owners_Database_Workspace\OwnerProperty.py "Lett" "PARCEL_SPI = '1\TP8994'"&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note cmd.exe /c may be a better choice, otherwise the shell continues to sit out there. Or you could just run Python directly:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;C:\&amp;gt; C:\Python27\ArcGIS10.1\python.exe ^ S:\MID_Owners_Database_Workspace\OwnerProperty.py "Lett" "PARCEL_SPI = '1\TP8994'"&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Mar 2013 21:58:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460158#M36036</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-03-07T21:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL error when using Python call argument</title>
      <link>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460159#M36037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for that. I'll give it a go and get back to you. PS I'm running VBA from Access&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Mar 2013 23:00:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460159#M36037</guid>
      <dc:creator>BobMCkay</dc:creator>
      <dc:date>2013-03-07T23:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL error when using Python call argument</title>
      <link>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460160#M36038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks. Works well.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Mar 2013 00:21:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-error-when-using-python-call-argument/m-p/460160#M36038</guid>
      <dc:creator>BobMCkay</dc:creator>
      <dc:date>2013-03-08T00:21:48Z</dc:date>
    </item>
  </channel>
</rss>

