Try to suppress output when setting password for postgresql

This commit is contained in:
Lance Edgar 2020-02-06 23:23:08 -06:00
parent 56acb30008
commit 88a08fcf8f

View file

@ -61,14 +61,14 @@ def reload(c):
c.sudo('systemctl reload postgresql.service')
def sql(c, sql, database='', port=None):
def sql(c, sql, database='', port=None, **kwargs):
"""
Execute some SQL as the 'postgres' user.
"""
cmd = 'psql {port} --tuples-only --no-align --command="{sql}" {database}'.format(
port='--port={}'.format(port) if port else '',
sql=sql, database=database)
return c.sudo(cmd, user='postgres')
return c.sudo(cmd, user='postgres', **kwargs)
def user_exists(c, name, port=None):
@ -97,9 +97,8 @@ def set_user_password(c, name, password, port=None):
"""
Set the password for a PostgreSQL user account
"""
# TODO: probably should figure out how to suppress echo for this command
# with hide('running'):
sql(c, "ALTER USER \\\"{}\\\" PASSWORD '{}';".format(name, password), port=port)
sql(c, "ALTER USER \\\"{}\\\" PASSWORD '{}';".format(name, password), port=port,
hide=True, echo=False)
def db_exists(c, name, port=None):