<?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: How to fetch playground DB data in a command in Active IQ Unified Manager Discussions</title>
    <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50525#M10392</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another approach which I use since it does not require installation of additional software (I believe that the .NET mysql modules will be included with future releases of WFA so the approach above will be appropriate then)...:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;### begin snip ###&lt;/P&gt;&lt;P&gt;# Default credentials for playground database&lt;/P&gt;&lt;P&gt;$MySQLAdminUserName = 'wfa'&lt;/P&gt;&lt;P&gt;$MySQLAdminPassword = 'Wfa123'&lt;/P&gt;&lt;P&gt;$MySQLDatabase = 'playground'&lt;/P&gt;&lt;P&gt;$MySQLHost = "localhost"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get-WFALogger -Info -message $("Obtaining MySQL location.")&lt;/P&gt;&lt;P&gt;# Attempt to find mysql.exe based on the wfa tmp working path, or default location if not found&lt;/P&gt;&lt;P&gt;$pwd = Get-Location&lt;/P&gt;&lt;P&gt;$mysqlcmd = $pwd.Path+"\..\..\..\..\mysql\bin\mysql.exe"&lt;/P&gt;&lt;P&gt;$mysqlcmd_found = Test-Path $mysqlcmd&lt;/P&gt;&lt;P&gt;if ($mysqlcmd_found -ne $true)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; $mysqlcmd = "$($env:ProgramFiles)\NetApp\WFA\mysql\bin\mysql.exe"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Get-WFALogger -Info -message $("Preparing Command")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; $cmd1 = "DELETE FROM playground.myTable " + &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "WHERE TargetCluster='$TargetCluster' AND "+ &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "TargetVserver='$TargetVserver' AND "+&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "TargetVolume='$TargetVolume'"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Get-WFALogger -Info -message $("Executing SQL: " + $cmd1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Attempt delete via mysql.exe&lt;/P&gt;&lt;P&gt;$output = &amp;amp; "$mysqlcmd" "--user=$MySQLAdminUserName" "--host=$MySQLHost" "--password=$MySQLAdminPassword" "-B" "-f" "-e$cmd1" "$MySQLDatabase" 2&amp;gt;&amp;amp;1&lt;/P&gt;&lt;P&gt;$ret = $?&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;if ($ret -eq $false) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw $("Operation failed: $output")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Aug 2014 11:12:18 GMT</pubDate>
    <dc:creator>ktim</dc:creator>
    <dc:date>2014-08-26T11:12:18Z</dc:date>
    <item>
      <title>How to fetch playground DB data in a command</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50500#M10381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create workflow where user enters a business unit name and command creates an export policy on a cluster whose data is stored in the playground database&lt;/P&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;I created a playground table that holds data abount business units and corresponding clusters and their IP addresses:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table bu (&lt;/P&gt;&lt;P&gt;&amp;nbsp; id int(11) not nul auto_increment primary key,&lt;/P&gt;&lt;P&gt;&amp;nbsp; bu varchar(255),&lt;/P&gt;&lt;P&gt;&amp;nbsp; cluster_name varchar(255),&lt;/P&gt;&lt;P&gt;&amp;nbsp; cluster_ip varchar(255),&lt;/P&gt;&lt;P&gt;&amp;nbsp; index(bu)&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I managed to create playground tables and successfully created filters and finders based on that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I cannot find out how to use information from SQL directly in a command.&lt;/P&gt;&lt;P&gt;I wanted to create a modification of "Create Export policy" command where user enters a business unit name and command creates an export policy on a cluster whose data is stored in the playground database, like this:&lt;/P&gt;&lt;PRE&gt;param (
&amp;nbsp; [parameter(Mandatory=$true, HelpMessage="Business Unit Name")]
&amp;nbsp; [string]$BU
)

&lt;SPAN style="color: #ff0000;"&gt;... I need to fetch here data from playground database, like this:
"select cluster_name from playground.bu_data where bu = '$BU"'
&lt;/SPAN&gt;# connect to controller
Connect-WfaCluster $Cluster&amp;nbsp; &amp;lt;====== &lt;SPAN style="color: #ff0000;"&gt;how can I get this $Cluster?&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any hint would be greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2025 05:30:00 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50500#M10381</guid>
      <dc:creator>SERVICEAMDS</dc:creator>
      <dc:date>2025-06-05T05:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch playground DB data in a command</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50505#M10383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a thread posted by mirko in communities on how to&lt;/P&gt;&lt;P&gt; run sql queries via command.&lt;/P&gt;&lt;P&gt;You can search in the same in communities.&lt;/P&gt;&lt;P&gt;I will try to send the link tomorrow if you can't find or if  nobody else responds.&lt;/P&gt;&lt;P&gt;Abhi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Aug 2014 16:16:31 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50505#M10383</guid>
      <dc:creator>abhit</dc:creator>
      <dc:date>2014-08-21T16:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch playground DB data in a command</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50510#M10385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a thread posted by mirko in communities on how to&lt;/P&gt;&lt;P&gt; run sql queries via command.&lt;/P&gt;&lt;P&gt;You can search in the same in communities.&lt;/P&gt;&lt;P&gt;I will try to send the link tomorrow if you can't find or if  nobody else responds.&lt;/P&gt;&lt;P&gt;Abhi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Aug 2014 16:26:43 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50510#M10385</guid>
      <dc:creator>abhit</dc:creator>
      <dc:date>2014-08-21T16:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch playground DB data in a command</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50515#M10388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The link referred to by Abhi is:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.netapp.com/docs/DOC-30478" title="https://communities.netapp.com/docs/DOC-30478" target="_blank"&gt;https://communities.netapp.com/docs/DOC-30478&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It has good examples on how to fetch data from playground DB&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shailaja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Aug 2014 16:48:24 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50515#M10388</guid>
      <dc:creator>shailaja</dc:creator>
      <dc:date>2014-08-21T16:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch playground DB data in a command</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50520#M10390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two ways to do it. You can pick what suits you better. Both have their advantages.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. You can declare $Cluster as another Input Parameter to your command. Something like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Param(&lt;/P&gt;&lt;P&gt;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...... &lt;/P&gt;&lt;P&gt;&amp;nbsp; [Parameter(Mandatory = $true,&amp;nbsp; HelpMessage="Cluster")]&lt;/P&gt;&lt;P&gt;&amp;nbsp; [string]$Cluster&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now in your workflow, you for this parameter declare variable as $Cluster_name and go to Setup &amp;gt; User-Inputs tab. Double-click to edit this variable input from &lt;SPAN style="color: #ff0000;"&gt;&lt;EM&gt;string&lt;/EM&gt;&lt;/SPAN&gt; to type: &lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Query&lt;/EM&gt;&lt;/SPAN&gt;. Now write your query and you get the Cluster.&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://community.netapp.com/legacyfs/online/26620_User-Input.png" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. You can make use of the mysql .NET connector and the attached powershell module to run queries directly from your command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Download and install on your WFA server&amp;nbsp; the mysql .NET &lt;STRONG style="font-size: 13px; color: #555555; font-family: verdana, arial, helvetica, sans-serif; background: #f3f3f3;"&gt;Windows (x86, 32-bit), MSI Installer&lt;/STRONG&gt; . &lt;A href="http://dev.mysql.com/downloads/connector/net/" title="http://dev.mysql.com/downloads/connector/net/" target="_blank"&gt;http://dev.mysql.com/downloads/connector/net/&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;You can use the below code snippet in your command to run mySQL queries directly from your command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;### begin snip ###&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$ConnectionString = "server=localhost;port=3306;uid=wfa;pwd=Wfa123"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Your query&lt;/P&gt;&lt;P&gt;$Query = "select * from playground.bu"&lt;/P&gt;&lt;P&gt;Try {&lt;/P&gt;&lt;P&gt;&amp;nbsp; [void][System.Reflection.Assembly]::LoadWithPartialName("MySql.Data")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; $Connection = New-Object MySql.Data.MySqlClient.MySqlConnection&lt;/P&gt;&lt;P&gt;&amp;nbsp; $Connection.ConnectionString = $ConnectionString&lt;/P&gt;&lt;P&gt;&amp;nbsp; $Connection.Open()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; $Command = New-Object MySql.Data.MySqlClient.MySqlCommand($Query, $Connection)&lt;/P&gt;&lt;P&gt;&amp;nbsp; $DataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($Command)&lt;/P&gt;&lt;P&gt;&amp;nbsp; $DataSet = New-Object System.Data.DataSet&lt;/P&gt;&lt;P&gt;&amp;nbsp; $DataAdapter.Fill($dataSet, "data")&lt;/P&gt;&lt;P&gt;# list of row objects&lt;/P&gt;&lt;P&gt;&amp;nbsp; $query_result = $DataSet.Tables[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Catch {&lt;/P&gt;&lt;P&gt;&amp;nbsp; Write-Host "ERROR : Unable to run query : $query `n$Error[0]"&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally {&lt;/P&gt;&lt;P&gt;&amp;nbsp; $Connection.Close()&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;## end snippet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 2nd option has some big advantages over the 1st one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Aug 2014 17:16:48 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50520#M10390</guid>
      <dc:creator>sinhaa</dc:creator>
      <dc:date>2014-08-21T17:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch playground DB data in a command</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50525#M10392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another approach which I use since it does not require installation of additional software (I believe that the .NET mysql modules will be included with future releases of WFA so the approach above will be appropriate then)...:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;### begin snip ###&lt;/P&gt;&lt;P&gt;# Default credentials for playground database&lt;/P&gt;&lt;P&gt;$MySQLAdminUserName = 'wfa'&lt;/P&gt;&lt;P&gt;$MySQLAdminPassword = 'Wfa123'&lt;/P&gt;&lt;P&gt;$MySQLDatabase = 'playground'&lt;/P&gt;&lt;P&gt;$MySQLHost = "localhost"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get-WFALogger -Info -message $("Obtaining MySQL location.")&lt;/P&gt;&lt;P&gt;# Attempt to find mysql.exe based on the wfa tmp working path, or default location if not found&lt;/P&gt;&lt;P&gt;$pwd = Get-Location&lt;/P&gt;&lt;P&gt;$mysqlcmd = $pwd.Path+"\..\..\..\..\mysql\bin\mysql.exe"&lt;/P&gt;&lt;P&gt;$mysqlcmd_found = Test-Path $mysqlcmd&lt;/P&gt;&lt;P&gt;if ($mysqlcmd_found -ne $true)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; $mysqlcmd = "$($env:ProgramFiles)\NetApp\WFA\mysql\bin\mysql.exe"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Get-WFALogger -Info -message $("Preparing Command")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; $cmd1 = "DELETE FROM playground.myTable " + &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "WHERE TargetCluster='$TargetCluster' AND "+ &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "TargetVserver='$TargetVserver' AND "+&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "TargetVolume='$TargetVolume'"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Get-WFALogger -Info -message $("Executing SQL: " + $cmd1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Attempt delete via mysql.exe&lt;/P&gt;&lt;P&gt;$output = &amp;amp; "$mysqlcmd" "--user=$MySQLAdminUserName" "--host=$MySQLHost" "--password=$MySQLAdminPassword" "-B" "-f" "-e$cmd1" "$MySQLDatabase" 2&amp;gt;&amp;amp;1&lt;/P&gt;&lt;P&gt;$ret = $?&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;if ($ret -eq $false) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw $("Operation failed: $output")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2014 11:12:18 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/How-to-fetch-playground-DB-data-in-a-command/m-p/50525#M10392</guid>
      <dc:creator>ktim</dc:creator>
      <dc:date>2014-08-26T11:12:18Z</dc:date>
    </item>
  </channel>
</rss>

