def delete_user(user_name: str):
"""Deletes a user's database, role and removes the entry from the user
database. Returns the `http_port` variable to deny access to ports.
Parameters
----------
user_name : str
Name of user account
"""
with psycopg2.connect(**PSQL_CONN) as conn:
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
cur.execute("""DELETE FROM {} WHERE user_name = '{}';"""
.format(PSQL_TABLE, user_name))
cur.execute("""DROP DATABASE {};""".format(user_name))
cur.execute("""DROP ROLE {};""".format(user_name))
conn.close()
click.secho('SUCCESS: User {} was removed from database.'
.format(user_name), fg='green')
postgres.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录