Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

more aggressively quote psql command lines

  • Loading branch information...
commit e7e1465c5075982fcc52f2a695b466f7fb96b004 1 parent 0c54c91
Erik LaBianca easel authored

Showing 1 changed file with 4 additions and 3 deletions. Show diff stats Hide diff stats

  1. +4 3 django_extensions/management/commands/restoredb.py
7 django_extensions/management/commands/restoredb.py
@@ -46,15 +46,16 @@ def do_postgresql_restore(self, infile):
46 46 from ... import settings
47 47 args = []
48 48 if settings.DB_USER:
49   - args += ["--username=%s" % settings.DB_USER]
  49 + args += ["--username=\"%s\"" % settings.DB_USER]
50 50 if settings.DB_HOST:
51 51 args += ["--host=%s" % settings.DB_HOST]
52 52 if settings.DB_PORT:
53 53 args += ["--port=%s" % settings.DB_PORT]
54 54 if settings.DB_NAME:
55 55 args += [settings.DB_NAME]
56   - os.system('PGPASSWORD=%s psql -c "drop schema public cascade; create schema public; alter schema public owner to %s" %s' % (
  56 + cmd = 'PGPASSWORD=%s psql -c "drop schema public cascade; create schema public; alter schema public owner to \\\"%s\\\"" %s' % (
57 57 settings.DB_PASSWD,
58 58 settings.DB_USER,
59   - ' '.join(args)))
  59 + ' '.join(args))
  60 + os.system(cmd)
60 61 os.system('PGPASSWORD=%s psql %s < %s' % (settings.DB_PASSWD, ' '.join(args), infile))

0 comments on commit e7e1465

Please sign in to comment.
Something went wrong with that request. Please try again.