mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-05-22 05:36:16 +03:00
Fixed example (with doctest) for Inet
This commit is contained in:
parent
9ba6102f66
commit
c72fbf0b0f
|
@ -8,6 +8,7 @@
|
||||||
.. testsetup::
|
.. testsetup::
|
||||||
|
|
||||||
import psycopg2.extras
|
import psycopg2.extras
|
||||||
|
from psycopg2.extras import Inet
|
||||||
|
|
||||||
create_test_table()
|
create_test_table()
|
||||||
|
|
||||||
|
@ -120,21 +121,28 @@ UUID data type
|
||||||
.. index::
|
.. index::
|
||||||
pair: INET; Data types
|
pair: INET; Data types
|
||||||
|
|
||||||
INET data type
|
:sql:`inet` data type
|
||||||
--------------
|
----------------------
|
||||||
|
|
||||||
|
.. versionadded:: 2.0.9
|
||||||
|
|
||||||
|
.. doctest::
|
||||||
|
|
||||||
>>> psycopg2.extras.register_inet()
|
>>> psycopg2.extras.register_inet()
|
||||||
<psycopg2._psycopg.type object at 0x...>
|
<psycopg2._psycopg.type object at 0x...>
|
||||||
>>> cur.execute("SELECT '192.168.0.1'::inet")
|
|
||||||
|
>>> cur.mogrify("SELECT %s", (Inet('127.0.0.1/32'),))
|
||||||
|
"SELECT E'127.0.0.1/32'::inet"
|
||||||
|
|
||||||
|
>>> cur.execute("SELECT '192.168.0.1/24'::inet")
|
||||||
>>> cur.fetchone()[0].addr
|
>>> cur.fetchone()[0].addr
|
||||||
'192.168.0.1'
|
'192.168.0.1/24'
|
||||||
|
|
||||||
|
|
||||||
.. autofunction:: register_inet()
|
.. autofunction:: register_inet()
|
||||||
|
|
||||||
.. autoclass:: Inet
|
.. autoclass:: Inet
|
||||||
|
|
||||||
.. todo:: Adapter non registered: how to register it?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
|
|
Loading…
Reference in New Issue
Block a user