diff --git a/postgresql/__init__.py b/postgresql/__init__.py index ca6c3ed..47cad00 100644 --- a/postgresql/__init__.py +++ b/postgresql/__init__.py @@ -1,18 +1,30 @@ +import sys from subprocess import check_output from pathlib import Path -import postgresql -pg_bin = Path(postgresql.__file__).parent / "bin" +pg_bin = Path(__file__).parent / "bin" -def initdb(cmdline): - cmdline = str(pg_bin / "initdb") + " " + cmdline - return check_output(cmdline, shell=True) +def prog(name): + def f(cmdline): + cmdline = str(pg_bin / name) + " " + cmdline + return check_output(cmdline, shell=True) + return f -def pg_ctl(cmdline): - cmdline = str(pg_bin / "pg_ctl") + " " + cmdline - return check_output(cmdline, shell=True) + +progs = """ +clusterdb ecpg pg_checksums pg_dumpall pg_restore pg_verifybackup reindexdb +createdb initdb pg_config pg_isready pg_rewind pg_waldump vacuumdb +createuser pg_archivecleanup pg_controldata pg_receivewal pg_test_fsync postgres +dropdb pg_basebackup pg_ctl pg_recvlogical pg_test_timing postmaster +dropuser pgbench pg_dump pg_resetwal pg_upgrade psql +""".split() + + +this = sys.modules[__name__] +for p in progs: + setattr(this, p, prog(p)) from . import _version