postgres.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:otree_virtual_machine_manager 作者: tobiasraabe 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号