本文整理匯總了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())
示例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
示例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
示例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)
示例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)