當前位置: 首頁>>代碼示例>>Python>>正文


Python extras.Inet方法代碼示例

本文整理匯總了Python中psycopg2.extras.Inet方法的典型用法代碼示例。如果您正苦於以下問題:Python extras.Inet方法的具體用法?Python extras.Inet怎麽用?Python extras.Inet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在psycopg2.extras的用法示例。


在下文中一共展示了extras.Inet方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_inet_conform

# 需要導入模塊: from psycopg2 import extras [as 別名]
# 或者: from psycopg2.extras import Inet [as 別名]
def test_inet_conform(self):
        from psycopg2.extras import Inet
        i = Inet("192.168.1.0/24")
        a = psycopg2.extensions.adapt(i)
        a.prepare(self.conn)
        self.assertEqual(
            filter_scs(self.conn, b("E'192.168.1.0/24'::inet")),
            a.getquoted())

        # adapts ok with unicode too
        i = Inet(u"192.168.1.0/24")
        a = psycopg2.extensions.adapt(i)
        a.prepare(self.conn)
        self.assertEqual(
            filter_scs(self.conn, b("E'192.168.1.0/24'::inet")),
            a.getquoted()) 
開發者ID:synthetichealth,項目名稱:syntheticmass,代碼行數:18,代碼來源:test_types_extras.py

示例2: value_to_db_ipaddress

# 需要導入模塊: from psycopg2 import extras [as 別名]
# 或者: from psycopg2.extras import Inet [as 別名]
def value_to_db_ipaddress(self, value):
        if value:
            return Inet(value)
        return None 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:6,代碼來源:operations.py

示例3: adapt_ipaddressfield_value

# 需要導入模塊: from psycopg2 import extras [as 別名]
# 或者: from psycopg2.extras import Inet [as 別名]
def adapt_ipaddressfield_value(self, value):
        if value:
            return Inet(value)
        return None 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:6,代碼來源:operations.py

示例4: testINET

# 需要導入模塊: from psycopg2 import extras [as 別名]
# 或者: from psycopg2.extras import Inet [as 別名]
def testINET(self):
        psycopg2.extras.register_inet()
        i = psycopg2.extras.Inet("192.168.1.0/24")
        s = self.execute("SELECT %s AS foo", (i,))
        self.failUnless(i.addr == s.addr)
        # must survive NULL cast to inet
        s = self.execute("SELECT NULL::inet AS foo")
        self.failUnless(s is None) 
開發者ID:synthetichealth,項目名稱:syntheticmass,代碼行數:10,代碼來源:test_types_extras.py

示例5: testINETARRAY

# 需要導入模塊: from psycopg2 import extras [as 別名]
# 或者: from psycopg2.extras import Inet [as 別名]
def testINETARRAY(self):
        psycopg2.extras.register_inet()
        i = psycopg2.extras.Inet("192.168.1.0/24")
        s = self.execute("SELECT %s AS foo", ([i],))
        self.failUnless(i.addr == s[0].addr)
        # must survive NULL cast to inet
        s = self.execute("SELECT NULL::inet[] AS foo")
        self.failUnless(s is None) 
開發者ID:synthetichealth,項目名稱:syntheticmass,代碼行數:10,代碼來源:test_types_extras.py


注:本文中的psycopg2.extras.Inet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。