test_types_extras.py 文件源码

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

项目:psycopg2-for-aws-lambda 作者: iwitaly 项目源码 文件源码
def test_register_globally(self):
        from psycopg2.extras import register_hstore, HstoreAdapter

        oids = HstoreAdapter.get_oids(self.conn)
        try:
            register_hstore(self.conn, globally=True)
            conn2 = self.connect()
            try:
                cur2 = self.conn.cursor()
                cur2.execute("select 'a => b'::hstore")
                r = cur2.fetchone()
                self.assertTrue(isinstance(r[0], dict))
            finally:
                conn2.close()
        finally:
            psycopg2.extensions.string_types.pop(oids[0][0])

        # verify the caster is not around anymore
        cur = self.conn.cursor()
        cur.execute("select 'a => b'::hstore")
        r = cur.fetchone()
        self.assertTrue(isinstance(r[0], str))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号