postgresql - How to run a bat file from a plpgsql function -
is there way run batch file function written in plpgsql
?
it's not possible directly pl/pgsql.
you can providing helper function in untrusted pl pl/perlu or pl/pythonu in turn runs batch file.
in python you'd use like:
create function exec_system_cmd (command text) returns return-type $$ import os import sys os.system(command) $$ language plpythonu;
or bit more sophisticated , use subprocess
module pass array of arguments instead, don't have worry escaping %
, >
, other special characters in command-string.
obviously exec_system_cmd
should executable superuser, , if possible, should instead write more specialized function doesn't let user run command like.
while possible, doesn't make idea. agree erwin it's better have outside helper program using listen
, notify
run commands when required.
Comments
Post a Comment