Skip to content
Browse files

more aggressively quote psql command lines

  • Loading branch information...
1 parent 0c54c91 commit e7e1465c5075982fcc52f2a695b466f7fb96b004 @easel easel committed Jan 26, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 django_extensions/management/commands/restoredb.py
View
7 django_extensions/management/commands/restoredb.py
@@ -46,15 +46,16 @@ def do_postgresql_restore(self, infile):
from ... import settings
args = []
if settings.DB_USER:
- args += ["--username=%s" % settings.DB_USER]
+ args += ["--username=\"%s\"" % settings.DB_USER]
if settings.DB_HOST:
args += ["--host=%s" % settings.DB_HOST]
if settings.DB_PORT:
args += ["--port=%s" % settings.DB_PORT]
if settings.DB_NAME:
args += [settings.DB_NAME]
- os.system('PGPASSWORD=%s psql -c "drop schema public cascade; create schema public; alter schema public owner to %s" %s' % (
+ cmd = 'PGPASSWORD=%s psql -c "drop schema public cascade; create schema public; alter schema public owner to \\\"%s\\\"" %s' % (
settings.DB_PASSWD,
settings.DB_USER,
- ' '.join(args)))
+ ' '.join(args))
+ os.system(cmd)
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.