mirror of
https://github.com/NaN-tic/python-erpdbcopy.git
synced 2023-12-14 04:53:00 +01:00
Add PostgreSQL 9.3 use case to kill postgresql processes
This commit is contained in:
parent
f0d9d1788a
commit
808a0f5e68
1 changed files with 14 additions and 1 deletions
|
@ -43,7 +43,7 @@ def create_db_copy(user, password, dbname, port=5432):
|
|||
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with nosuperuser"
|
||||
export PGPASSWORD=""" % {'user': user, 'password': password, 'dbname': dbname}, shell=True)
|
||||
process.wait()
|
||||
else:
|
||||
elif version == '9.2':
|
||||
process = subprocess.Popen("""
|
||||
export PGPASSWORD="erpdbcopy"
|
||||
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with superuser"
|
||||
|
@ -56,6 +56,19 @@ def create_db_copy(user, password, dbname, port=5432):
|
|||
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with nosuperuser"
|
||||
export PGPASSWORD=""" % {'user': user, 'password': password, 'dbname': dbname}, shell=True)
|
||||
process.wait()
|
||||
else:
|
||||
process = subprocess.Popen("""
|
||||
export PGPASSWORD="erpdbcopy"
|
||||
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with superuser"
|
||||
export PGPASSWORD=%(password)s
|
||||
psql %(dbname)s -U %(user)s --quiet -c "select pg_terminate_backend(pid) from pg_stat_activity where pid <> pg_backend_pid() and datname='%(dbname)s'"
|
||||
psql %(dbname)s_test -U %(user)s --quiet -c "select pg_terminate_backend(pid) from pg_stat_activity where pid <> pg_backend_pid() and datname='%(dbname)s_test'"
|
||||
dropdb -U %(user)s %(dbname)s_test
|
||||
createdb -U %(user)s -T %(dbname)s %(dbname)s_test -O %(user)s
|
||||
export PGPASSWORD="erpdbcopy"
|
||||
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with nosuperuser"
|
||||
export PGPASSWORD=""" % {'user': user, 'password': password, 'dbname': dbname}, shell=True)
|
||||
process.wait()
|
||||
|
||||
try:
|
||||
logging.info('Dissable crons copy: %s_test' % dbname)
|
||||
|
|
Loading…
Reference in a new issue