saltstack/salt — pull request #4349 by nmandery (2013-04-02 13:17:13+00:00)
Title: Use Postgresql CSV export to read data from the database

I just noticed the postgresql command relies on parsing the formatted output of the psql command to read data from the db. The result is read as a string and split at the column separators ( '|' ).

This method is very error-prone and also ignores the fact that postgresql supports CSV as an ouput format natively, which has far better parser support. This pull request switches to CSV as default format to read from the database and uses pythons csv module to parse the returned data. To reduce the amount of duplicated parsing code, I replaced the database queries in the user_list and db_list commands with the new psql_query function.

This pull request also adds the psql_query command which allows performing arbitrary select queries via salt.