mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-23 01:16:34 +03:00
Index and targets for subclassing work again.
This commit is contained in:
parent
323340abc6
commit
edc690e60a
|
@ -3,13 +3,6 @@ More advanced topics
|
||||||
|
|
||||||
.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||||
|
|
||||||
.. index::
|
|
||||||
double: Subclassing; Cursor
|
|
||||||
double: Subclassing; Connection
|
|
||||||
|
|
||||||
.. _subclassing-connection:
|
|
||||||
.. _subclassing-cursor:
|
|
||||||
|
|
||||||
.. testsetup:: *
|
.. testsetup:: *
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
@ -17,6 +10,13 @@ More advanced topics
|
||||||
cur.execute("CREATE TABLE atable (apoint point)")
|
cur.execute("CREATE TABLE atable (apoint point)")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
.. index::
|
||||||
|
double: Subclassing; Cursor
|
||||||
|
double: Subclassing; Connection
|
||||||
|
|
||||||
|
.. _subclassing-connection:
|
||||||
|
.. _subclassing-cursor:
|
||||||
|
|
||||||
Connection and cursor factories
|
Connection and cursor factories
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
|
@ -145,7 +145,9 @@ user-defined), its OID must be known. It can be retrieved either by the second
|
||||||
column of the :attr:`cursor.description`:
|
column of the :attr:`cursor.description`:
|
||||||
|
|
||||||
>>> cur.execute("SELECT NULL::point")
|
>>> cur.execute("SELECT NULL::point")
|
||||||
>>> point_oid = cur.description[0][1] # usually returns 600
|
>>> point_oid = cur.description[0][1]
|
||||||
|
>>> point_oid
|
||||||
|
600
|
||||||
|
|
||||||
or by querying the system catalogs for the type name and namespace (the
|
or by querying the system catalogs for the type name and namespace (the
|
||||||
namespace for system objects is :sql:`pg_catalog`):
|
namespace for system objects is :sql:`pg_catalog`):
|
||||||
|
@ -158,6 +160,8 @@ namespace for system objects is :sql:`pg_catalog`):
|
||||||
... AND nspname = %(namespace)s""",
|
... AND nspname = %(namespace)s""",
|
||||||
... {'typename': 'point', 'namespace': 'pg_catalog'})
|
... {'typename': 'point', 'namespace': 'pg_catalog'})
|
||||||
>>> point_oid = cur.fetchone()[0]
|
>>> point_oid = cur.fetchone()[0]
|
||||||
|
>>> point_oid
|
||||||
|
600
|
||||||
|
|
||||||
After you know the object OID, you must can and register the new type:
|
After you know the object OID, you must can and register the new type:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user