Python psycopg2.extras.Inet() Examples

The following are 10 code examples of psycopg2.extras.Inet(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module psycopg2.extras , or try the search function .
Example #1
Source File: test_types_extras.py    From syntheticmass with Apache License 2.0 6 votes vote down vote up
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()) 
Example #2
Source File: operations.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def value_to_db_ipaddress(self, value):
        if value:
            return Inet(value)
        return None 
Example #3
Source File: operations.py    From bioforum with MIT License 5 votes vote down vote up
def adapt_ipaddressfield_value(self, value):
        if value:
            return Inet(value)
        return None 
Example #4
Source File: operations.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def adapt_ipaddressfield_value(self, value):
        if value:
            return Inet(value)
        return None 
Example #5
Source File: operations.py    From python with Apache License 2.0 5 votes vote down vote up
def adapt_ipaddressfield_value(self, value):
        if value:
            return Inet(value)
        return None 
Example #6
Source File: operations.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def adapt_ipaddressfield_value(self, value):
        if value:
            return Inet(value)
        return None 
Example #7
Source File: operations.py    From opentaps_seas with GNU Lesser General Public License v3.0 5 votes vote down vote up
def adapt_ipaddressfield_value(self, value):
        if value:
            return Inet(value)
        return None 
Example #8
Source File: operations.py    From python2017 with MIT License 5 votes vote down vote up
def adapt_ipaddressfield_value(self, value):
        if value:
            return Inet(value)
        return None 
Example #9
Source File: test_types_extras.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
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) 
Example #10
Source File: test_types_extras.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
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)