示例#1
0
def export(filename=None):
  if not filename:
    filename = "%s.sql" % DB_NAME

  if os.path.isfile(filename) and not yes_or_no_input("That file already exists. Overwrite?"):
    print "Aborting..."
    return
  else:
    print "Exporting %s to %s" % (DB_NAME, filename)
    sudo("pg_dumpall -f %s -c %s" % (filename, DB_NAME), user=POSTGRES_ADMIN_USER)
示例#2
0
def drop_user(user):
  if yes_or_no_input("Are you sure you want to drop the user %s?" % user):
    sudo('psql -c "DROP USER %s"' % (user), user=POSTGRES_ADMIN_USER)
  else:
    print "Skipping drop"
    return False
示例#3
0
def drop_db(name):
  if yes_or_no_input("Are you sure you want to drop the database %s?" % name):
    sudo("dropdb %s" % name, user=POSTGRES_ADMIN_USER)
  else:
    print "Skipping drop"
    return False