def get_user(user_name: str):
"""Returns a user entry from PostgreSQL table.
Returns
-------
dict_user : dict
A dictionary with user information
"""
with psycopg2.connect(cursor_factory=RealDictCursor,
**PSQL_CONN) as conn:
dict_cur = conn.cursor()
dict_cur.execute(
"""SELECT * FROM {} WHERE user_name = '{}';"""
.format(PSQL_TABLE, user_name))
dict_user = dict_cur.fetchone()
conn.close()
return dict_user
postgres.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录