<?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: Is a query result a lit or or a dict? in Cortex XSOAR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484703#M815</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/218112"&gt;@Tripper&lt;/a&gt;, Just to add on to&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/201814"&gt;@tyler_bailey&lt;/a&gt;&amp;nbsp;response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Downloaded as a file. it is an odd | delimited file.&lt;/EM&gt; - This is a markdown file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you would need to output the response like this.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;return_results({
    'Type': entryTypes['note'],
    'ContentsFormat': formats['markdown'],
    'Contents': current_unique_IDs, outputTable)
    })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also force the string like below.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;demisto.results(str(current_unique_IDs))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 May 2022 00:41:25 GMT</pubDate>
    <dc:creator>jfernandes1</dc:creator>
    <dc:date>2022-05-04T00:41:25Z</dc:date>
    <item>
      <title>Is a query result a lit or or a dict?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484566#M811</link>
      <description>&lt;P&gt;Hey there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running a query -&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;current_unique_IDs = demisto.executeCommand(&lt;/SPAN&gt;&lt;SPAN&gt;"query"&lt;/SPAN&gt;&lt;SPAN&gt;, {&lt;/SPAN&gt;&lt;SPAN&gt;"query"&lt;/SPAN&gt;&lt;SPAN&gt;:get_current_uniqueIDs_query_SQL, &lt;/SPAN&gt;&lt;SPAN&gt;"using-brand"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;"Generic SQL"&lt;/SPAN&gt;&lt;SPAN&gt;})&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;when i execute -&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;demisto.results(&lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt;&lt;SPAN&gt;(current_unique_IDs)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;I get&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tripper_0-1651598898339.png" style="width: 400px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/40829iEEA1C44DC4B9DEE0/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Tripper_0-1651598898339.png" alt="Tripper_0-1651598898339.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when i try list functions it says it is a dict. but when i try to do dict functions I get a non hashable error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the query object, preferable as a set, to filter a dataframe. So what python type is a query result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Downloaded as a file. it is an odd | delimited file.&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tripper_0-1651599849700.png" style="width: 400px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/40831i4CB18067EB8343E8/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Tripper_0-1651599849700.png" alt="Tripper_0-1651599849700.png" /&gt;&lt;/span&gt;&lt;P&gt;This appears to be neither a dict or a list. Anyone have a link or gist on how to best deal with this data to get it in a list, or set?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your time.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 May 2022 17:46:23 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484566#M811</guid>
      <dc:creator>Tripper</dc:creator>
      <dc:date>2022-05-03T17:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Is a query result a lit or or a dict?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484586#M812</link>
      <description>&lt;P&gt;The return of demisto.execute() is a list of dicts. You can use pformat() to view the structure of the return object.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pprint import pformat
demisto.results(pformat(current_unique_IDs))&lt;/LI-CODE&gt;&lt;P&gt;I like pformat() because it prints the output with clear spacing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results you are after are probably going to be in&lt;/P&gt;&lt;LI-CODE lang="python"&gt;current_unique_IDs[0]["Contents"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also suggest taking a look at &lt;A href="https://github.com/demisto/content/blob/master/Packs/Base/Scripts/CommonServerPython/CommonServerPython.py#L6627" target="_self"&gt;execute_command()&lt;/A&gt;, it does some additional error checking for you and extracts the contents from the returned data so you don't have to do `current_unique_IDs[0]["Contents"]`, it does it for you. It's a drop in replacement for demisto.executeCommand(), so it would look like&lt;/P&gt;&lt;LI-CODE lang="python"&gt;current_unique_IDs = execute_command("query", {"query":get_current_uniqueIDs_query_SQL, "using-brand":"Generic SQL"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, &lt;A href="https://xsoar.pan.dev/docs/integrations/code-conventions#deprecated---demistoresults" target="_self"&gt;demisto.results()&lt;/A&gt; is deprecated. The recommendation now is to use return_results(). Which from your example above, would just be this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;return_results(type(current_unique_IDs))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 18:03:57 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484586#M812</guid>
      <dc:creator>tyler_bailey</dc:creator>
      <dc:date>2022-05-03T18:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Is a query result a lit or or a dict?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484589#M813</link>
      <description>&lt;P&gt;great response Tyler.&amp;nbsp; Appreciate you learning my up a bit.&lt;/P&gt;&lt;P&gt;Everything worked as expected. I will mark the response as resolved. But one more question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I searched for documentation on&amp;nbsp;&lt;SPAN&gt;execute_command(&lt;/SPAN&gt;&lt;SPAN&gt;"query" and&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;demisto.executeCommand("query looking specificaly for attribute for the query command, but couldn't find a reference for it. I am looking to set the size of the return set.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;i tried&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;execute_command(&lt;/SPAN&gt;&lt;SPAN&gt;"query"&lt;/SPAN&gt;&lt;SPAN&gt;, {&lt;/SPAN&gt;&lt;SPAN&gt;"query"&lt;/SPAN&gt;&lt;SPAN&gt;:get_current_uniqueIDs_query_SQL, &lt;/SPAN&gt;&lt;SPAN&gt;"using-brand"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;"Generic SQL"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"size"&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;30000&lt;/SPAN&gt;&lt;SPAN&gt;})&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;but that failed&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tripper_0-1651605448824.png" style="width: 400px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/40835i1CC8C3D0E9837C0C/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Tripper_0-1651605448824.png" alt="Tripper_0-1651605448824.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any chance you have a link that document the query execute_command or let me the attribute syntax for size?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 May 2022 19:18:16 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484589#M813</guid>
      <dc:creator>Tripper</dc:creator>
      <dc:date>2022-05-03T19:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is a query result a lit or or a dict?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484613#M814</link>
      <description>&lt;P&gt;So the parameters for "query" aren't going to be listed under the documentation for "execute_command". "execute_command" is just a function to call a specific command within XSOAR. The command that you are calling is "query". You can see the parameters that are accepted for that command in the XSOAR GUI by first clicking the "!" next to the cli at the bottom of the page&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tyler_bailey_1-1651606006980.png" style="width: 400px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/40837i4F77FEED9AED887E/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="tyler_bailey_1-1651606006980.png" alt="tyler_bailey_1-1651606006980.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And then you can search for the command you are running, then click run.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tyler_bailey_0-1651605975912.png" style="width: 400px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/40836iC4A26C3BF1C39207/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="tyler_bailey_0-1651605975912.png" alt="tyler_bailey_0-1651605975912.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This will show you the available arguments for the command that is selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also view the command arguments by viewing the integration code on the settings page, but the Commands and Scripts view via the GUI CLI is "prettier".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case I believe you would want the "limit" argument, which defaults to 50. So the code would look like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;current_unique_IDs = execute_command("query", {"query":get_current_uniqueIDs_query_SQL, "using-brand":"Generic SQL", "limit":30000})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also of note, the "query" command from the Generic SQL Integration is deprecated. Looks like it's recommended to use "sql-command" in place. It looks like the command arguments are the same so you should be able to just replace "query" with "sql-command".&lt;/P&gt;&lt;LI-CODE lang="python"&gt;current_unique_IDs = execute_command("sql-command", {"query":get_current_uniqueIDs_query_SQL, "using-brand":"Generic SQL", "limit":30000})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 19:34:51 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484613#M814</guid>
      <dc:creator>tyler_bailey</dc:creator>
      <dc:date>2022-05-03T19:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is a query result a lit or or a dict?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484703#M815</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/218112"&gt;@Tripper&lt;/a&gt;, Just to add on to&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/201814"&gt;@tyler_bailey&lt;/a&gt;&amp;nbsp;response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Downloaded as a file. it is an odd | delimited file.&lt;/EM&gt; - This is a markdown file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you would need to output the response like this.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;return_results({
    'Type': entryTypes['note'],
    'ContentsFormat': formats['markdown'],
    'Contents': current_unique_IDs, outputTable)
    })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also force the string like below.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;demisto.results(str(current_unique_IDs))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 00:41:25 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484703#M815</guid>
      <dc:creator>jfernandes1</dc:creator>
      <dc:date>2022-05-04T00:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is a query result a lit or or a dict?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484904#M818</link>
      <description>&lt;P&gt;that's pretty Clean. Appreciate that snippet!&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 15:09:30 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484904#M818</guid>
      <dc:creator>Tripper</dc:creator>
      <dc:date>2022-05-04T15:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is a query result a lit or or a dict?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484905#M819</link>
      <description>&lt;P&gt;appreciate the depth of the response!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 15:10:23 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-a-query-result-a-lit-or-or-a-dict/m-p/484905#M819</guid>
      <dc:creator>Tripper</dc:creator>
      <dc:date>2022-05-04T15:10:23Z</dc:date>
    </item>
  </channel>
</rss>

