From edc690e60ae34bf76b3a8f7e9008fc2b2b2aacf0 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sun, 14 Feb 2010 04:59:40 +0000 Subject: [PATCH] Index and targets for subclassing work again. --- doc/advanced.rst | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/advanced.rst b/doc/advanced.rst index 8f5dcf33..64aa7044 100644 --- a/doc/advanced.rst +++ b/doc/advanced.rst @@ -3,13 +3,6 @@ More advanced topics .. sectionauthor:: Daniele Varrazzo -.. index:: - double: Subclassing; Cursor - double: Subclassing; Connection - -.. _subclassing-connection: -.. _subclassing-cursor: - .. testsetup:: * import re @@ -17,6 +10,13 @@ More advanced topics cur.execute("CREATE TABLE atable (apoint point)") conn.commit() +.. index:: + double: Subclassing; Cursor + double: Subclassing; Connection + +.. _subclassing-connection: +.. _subclassing-cursor: + 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`: >>> 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 namespace for system objects is :sql:`pg_catalog`): @@ -158,6 +160,8 @@ namespace for system objects is :sql:`pg_catalog`): ... AND nspname = %(namespace)s""", ... {'typename': 'point', 'namespace': 'pg_catalog'}) >>> point_oid = cur.fetchone()[0] + >>> point_oid + 600 After you know the object OID, you must can and register the new type: