当前位置: 首页>>代码示例>>Python>>正文


Python momoko.connect函数代码示例

本文整理汇总了Python中momoko.connect函数的典型用法代码示例。如果您正苦于以下问题:Python connect函数的具体用法?Python connect怎么用?Python connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了connect函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_setsession

    def test_setsession(self):
        """Testing that setssion parameter is honoured"""
        setsession = deque([None, "SELECT 1", "SELECT 2"])
        time_zones = ["UTC", "Israel", "Australia/Melbourne"]

        for i in range(len(time_zones)):
            setsession[i] = "SET TIME ZONE '%s'" % time_zones[i]
            conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, setsession=setsession)
            cursor = yield conn.execute("SELECT current_setting('TIMEZONE');")
            self.assertEqual(cursor.fetchall(), [(time_zones[i],)])
            conn.close()
            setsession.rotate(1)
开发者ID:FSX,项目名称:momoko,代码行数:12,代码来源:tests.py

示例2: test_cursor_factory_with_json

 def test_cursor_factory_with_json(self):
     """Testing that register_json works with RealDictCursor"""
     conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, cursor_factory=RealDictCursor)
     yield conn.register_json()
     cursor = yield conn.execute("SELECT 1 AS a")
     self.assertEqual(cursor.fetchone(), {"a": 1})
开发者ID:FSX,项目名称:momoko,代码行数:6,代码来源:tests.py

示例3: test_ping_with_named_cursor

 def test_ping_with_named_cursor(self):
     """Test whether Connection.ping works fine with named cursors. Issue #74"""
     conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, cursor_factory=RealDictCursor)
     yield conn.ping()
开发者ID:FSX,项目名称:momoko,代码行数:4,代码来源:tests.py

示例4: test_connection_factory

 def test_connection_factory(self):
     """Testing that connection_factory parameter is properly propagated"""
     conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, connection_factory=RealDictConnection)
     cursor = yield conn.execute("SELECT 1 AS a")
     self.assertEqual(cursor.fetchone(), {"a": 1})
开发者ID:FSX,项目名称:momoko,代码行数:5,代码来源:tests.py

示例5: test_bad_connect_local

 def test_bad_connect_local(self):
     """Test that Connection raises connection errors when using local socket"""
     try:
         yield momoko.connect(local_bad_dsn, ioloop=self.io_loop)
     except Exception as error:
         self.assertIsInstance(error, psycopg2.OperationalError)
开发者ID:FSX,项目名称:momoko,代码行数:6,代码来源:tests.py

示例6: test_connect

 def test_connect(self):
     """Test that Connection can connect to the database"""
     conn = yield momoko.connect(good_dsn, ioloop=self.io_loop)
     self.assertIsInstance(conn, momoko.Connection)
开发者ID:FSX,项目名称:momoko,代码行数:4,代码来源:tests.py

示例7: set_up_10

 def set_up_10(self):
     self.conn = yield momoko.connect(self.dsn, ioloop=self.io_loop)
     for g in chain(self.clean_db(), self.prepare_db()):
         yield g
开发者ID:FSX,项目名称:momoko,代码行数:4,代码来源:tests.py

示例8: test_bad_connect

 def test_bad_connect(self):
     """Test that Connection raises connection errors"""
     try:
         conn = yield momoko.connect(bad_dsn, ioloop=self.io_loop)
     except Exception as error:
         self.assertIsInstance(error, psycopg2.OperationalError)
开发者ID:XuTuKe,项目名称:momoko,代码行数:6,代码来源:tests.py


注:本文中的momoko.connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。