Skip to content

Commit f30f926

Browse files
committed
use long syntax for pg_dump command
why: explicit is always better, by removing confusion on uncommon options
1 parent d72a45b commit f30f926

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

pganonymize/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ def create_database_dump(filename, db_args):
298298
env_vars = ''
299299
if db_args.get('password'):
300300
env_vars += 'PGPASSWORD={password}'.format(password=db_args['password'])
301-
arguments = '-d {dbname} -U {user} -h {host} -p {port}'.format(**db_args)
302-
cmd = '{env_vars}pg_dump -Fc -Z 9 {args} -f {filename}'.format(
301+
arguments = '--dbname {dbname} --username {user} --host {host} --port {port}'.format(**db_args)
302+
cmd = '{env_vars}pg_dump --format custom --compress 9 {args} --file {filename}'.format(
303303
env_vars='{} '.format(env_vars) if env_vars else '',
304304
args=arguments,
305305
filename=filename

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class TestCli(object):
5656
call('UPDATE "auth_user" t SET "first_name" = s."first_name", "last_name" = s."last_name", "email" = s."email" FROM "tmp_auth_user" s WHERE t."id" = s."id"') # noqa
5757
],
5858
1,
59-
[call('PGPASSWORD=my-cool-password pg_dump -Fc -Z 9 -d db -U root -h localhost -p 5432 -f ./dump.sql', shell=True)] # noqa
59+
[call('PGPASSWORD=my-cool-password pg_dump --format custom --compress 9 --dbname db --username root --host localhost --port 5432 --file ./dump.sql', shell=True)] # noqa
6060
],
6161
6262
['--list-providers --parallel',

tests/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test(self, mock_call):
241241
{'dbname': 'database', 'user': 'foo', 'host': 'localhost', 'port': 5432},
242242
)
243243
mock_call.assert_called_once_with(
244-
'pg_dump -Fc -Z 9 -d database -U foo -h localhost -p 5432 -f /tmp/dump.gz',
244+
'pg_dump --format custom --compress 9 --dbname database --username foo --host localhost --port 5432 --file /tmp/dump.gz',
245245
shell=True,
246246
)
247247

@@ -252,6 +252,6 @@ def test_with_password(self, mock_call):
252252
{'dbname': 'database', 'user': 'foo', 'host': 'localhost', 'port': 5432, 'password': 'pass'},
253253
)
254254
mock_call.assert_called_once_with(
255-
'PGPASSWORD=pass pg_dump -Fc -Z 9 -d database -U foo -h localhost -p 5432 -f /tmp/dump.gz',
255+
'PGPASSWORD=pass pg_dump --format custom --compress 9 --dbname database --username foo --host localhost --port 5432 --file /tmp/dump.gz',
256256
shell=True,
257257
)

0 commit comments

Comments
 (0)