# subject to the above copyright notice and this permission notice shall being included # in all copies or substantial portions of the Software. # -- config -- # description: Retrieve a list of roles. # http_method: get # lock: False # tags: Postgres, Psql # -- end config -- from os import linesep from extension import CmdRun, ToolKit, Constants # Spawn Instances run = CmdRun() # <class> Run toolkit = ToolKit() # <class> Misc. functions # ****************** # * SQL SENTENCE * # ****************** sql = ("\du") sql_code = toolkit.write_temp(sql) # **************** # * SQL RUNNER * # **************** output = run.sql(sql_code) print(output) print("{status}=ok".format(status=Constants.API_SUMMARY_STRING)) toolkit.exit(0)
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the above copyright notice and this permission notice shall being included # in all copies or substantial portions of the Software. # -- config -- # description: Retrieve pg stats connection activity (whos connected) # http_method: get # lock: False # tags: Postgres, PGaaS, cit-ops # -- end config -- from extension import ToolKit, CmdRun, Constants # Spawn Instances toolkit = ToolKit() run = CmdRun() # <class> Run # ****************** # * SQL SENTENCE * # ****************** sql = ("BEGIN; select * from pg_stat_activity; COMMIT;") sql_code = toolkit.write_temp(sql) # **************** # * SQL RUNNER * # **************** output = run.sql(sql_code) # ********************** # * OUTPUT PROCESSOR *