I am trying to parse SQL output from a command, it doesn't and cannot connect using a native library like the MySQL .Net Connector, but the output is 'the same'. Is there any way to parse its output into a table, and search the rows etc, like I was using the connector?
PS> plesk db "SELECT d.name,h.php_handler_id FROM domains d JOIN hosting h ON h.dom_id=d.id WHERE h.php_handler_id NOT LIKE '%fastcgi-5.6%' OR '%fastcgi-7%';" +-----------------------------------------------------+----------------+ | name | php_handler_id | +-----------------------------------------------------+----------------+ | cms.123.com | cgi- | | 99923.com | cgi- | | cms4.123.com | cgi-4 | -----------------------------------------------------------------------
So I can then use the name/handler variables and print them.
From the plesk
utility documentation:
db
anddb dump
commands can be followed by mysql and mysqldump options respectively:
The mysql
command has a parameter -B
that generates tab-separated output instead of tabular output, so you should be able to do something like this:
$result = plesk db -B "SELECT ..." | ConvertFrom-Csv -Delimiter "`t"