<?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: Select by attribute using get parameter as text with Enterprise Geodatabase. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580265#M73674</link>
    <description>&lt;P&gt;Suspect the issue is with the .split(";") being incorporated into the qry statement.&lt;/P&gt;&lt;P&gt;What happens if you put a print(qry) line in between lines 7&amp;nbsp; &amp;amp; 8?&lt;/P&gt;&lt;P&gt;Didn't test with GetParameter..., but if I set the Station = '276':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&amp;gt;&amp;gt;&amp;gt; select_stations = "276"
&amp;gt;&amp;gt;&amp;gt; qry = "{0} IN ({1})".format(arcpy.AddFieldDelimiters(datasource= firestations, field = 'STATIONID'), ', '.join(select_stations))
&amp;gt;&amp;gt;&amp;gt; print(qry)
STATIONID IN (2, 7, 6)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then&amp;nbsp; you can make the modifications to get the proper query statement.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jan 2025 23:58:34 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2025-01-29T23:58:34Z</dc:date>
    <item>
      <title>Select by attribute using get parameter as text with Enterprise Geodatabase.</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580257#M73672</link>
      <description>&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.env.workspace = r"C:\PPCAnalysis\PPCAnalyis\PPCAnalyis.gdb"
select_stations = arcpy.GetParameterAsText(0).split(";")
firestations = r"C:\PPCAnalysis\PPCAnalyis\ISRB_DATA.sde\DBO.FireStations"

qry = "{0} IN ({1})".format(arcpy.AddFieldDelimiters(datasource= firestations, field = 'STATIONID'), ', '.join(select_stations))
selected_stations = arcpy.management.SelectLayerByAttribute(in_layer_or_view= firestations, where_clause=qry)

arcpy.SelectLayerByAttribute_management(in_layer_or_view=firestations, where_clause= qry)&lt;/LI-CODE&gt;&lt;P&gt;I am trying to develop a custom tool where the user can enter "STATIONID" for a fire station, and it will select it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The fire station feature class is being stored in an Enterprise Geodatabase, and when I enter the parameter (see screenshot), it says it was successful.&amp;nbsp; However, when I open the attribute table, nothing is actually being selected.&amp;nbsp; Also, neither is the point on the map.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-01-29 163549.png" style="width: 579px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124327i352EB4231C3EB44A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-01-29 163549.png" alt="Screenshot 2025-01-29 163549.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For future development reasons I do want the selection to be made directly from the enterprise geodatabase.&amp;nbsp; Thanks so much for the help&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 23:38:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580257#M73672</guid>
      <dc:creator>ColeNelson</dc:creator>
      <dc:date>2025-01-29T23:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute using get parameter as text with Enterprise Geodatabase.</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580264#M73673</link>
      <description>&lt;P&gt;My bet is twofold: 1) your parameter is actually text, in which case if your field is a number field, the query will run just fine but not select anything. Change the parameter type to Long (integer) if it isn't already, and/or 2) having made the parameter an integer, use GetParameter(0) instead, which will return the true value instead of a string.&lt;/P&gt;&lt;P&gt;alternatively, you can pop an int() around line 4, if you trust your users to input numbers.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 23:58:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580264#M73673</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-01-29T23:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute using get parameter as text with Enterprise Geodatabase.</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580265#M73674</link>
      <description>&lt;P&gt;Suspect the issue is with the .split(";") being incorporated into the qry statement.&lt;/P&gt;&lt;P&gt;What happens if you put a print(qry) line in between lines 7&amp;nbsp; &amp;amp; 8?&lt;/P&gt;&lt;P&gt;Didn't test with GetParameter..., but if I set the Station = '276':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&amp;gt;&amp;gt;&amp;gt; select_stations = "276"
&amp;gt;&amp;gt;&amp;gt; qry = "{0} IN ({1})".format(arcpy.AddFieldDelimiters(datasource= firestations, field = 'STATIONID'), ', '.join(select_stations))
&amp;gt;&amp;gt;&amp;gt; print(qry)
STATIONID IN (2, 7, 6)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then&amp;nbsp; you can make the modifications to get the proper query statement.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 23:58:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580265#M73674</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2025-01-29T23:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute using get parameter as text with Enterprise Geodatabase.</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580274#M73675</link>
      <description>&lt;P&gt;Does the tool work better if you add that feature class to a map as a layer, then use the layer specifically? I've found using Select By Attribute/Location on feature class paths is flaky.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 00:49:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-using-get-parameter-as-text/m-p/1580274#M73675</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-30T00:49:00Z</dc:date>
    </item>
  </channel>
</rss>

