本文整理汇总了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)