Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

README updates

  • Loading branch information...
commit d13392bedcd2921ba0c852e385330e579776177a 1 parent 4f303b4
mike bayer authored October 26, 2012
11  README.rst
Source Rendered
@@ -49,10 +49,11 @@ Above, we've selected from a table ``customers``, including a nested
49 49
 result set for ``orders``.  Within that of ``orders``, we have another
50 50
 nested result against ``items``. Inspecting ``cursor.description``, we
51 51
 see the three outermost columns represented, all normally except for
52  
-``orders`` which has a special typecode ``NESTED_CURSOR``::
  52
+``orders`` which has a special typecode "5001", which will compare as
  53
+``True`` to the ``akiban.api.NESTED_CURSOR`` DBAPI constant::
53 54
 
54 55
   >>> cursor.description
55  
-  [(u'customer_id', <psycopg2._psycopg.type 'INTEGER' at 0x10060a368>, None, None, None, None, None), (u'name', <psycopg2._psycopg.type 'STRING' at 0x10060a4c8>, None, None, None, None, None), (u'orders', <object object at 0x1002af0c0>, None, None, None, None, None)]
  56
+  [(u'customer_id', 23, None, None, None, None, None), (u'name', 1043, None, None, None, None, None), (u'orders', 5001, None, None, None, None, None)]
56 57
 
57 58
 If we fetch the first row, it looks mostly normal except for one column that contains a "nested cursor"::
58 59
 
@@ -64,7 +65,7 @@ looking at the ``orders`` column, we can see that the value is itself a cursor,
64 65
 
65 66
   >>> subcursor = row[2]
66 67
   >>> subcursor.description
67  
-  [(u'order_id', <psycopg2._psycopg.type 'INTEGER' at 0x10060a368>, None, None, None, None, None), (u'order_info', <psycopg2._psycopg.type 'STRING' at 0x10060a4c8>, None, None, None, None, None), (u'items', <object object at 0x1002af0c0>, None, None, None, None, None)]
  68
+  [(u'order_id', 23, None, None, None, None, None), (u'order_info', 1043, None, None, None, None, None), (u'items', 5001, None, None, None, None, None)]
68 69
 
69 70
 Fetching a row from this cursor, we see it has its own nested data::
70 71
 
@@ -76,7 +77,7 @@ and continuing the process, we can see ``items`` column of this row contains ano
76 77
 
77 78
   >>> subsubcursor = subrow[2]
78 79
   >>> subsubcursor.description
79  
-  [(u'item_id', <psycopg2._psycopg.type 'INTEGER' at 0x10060a368>, None, None, None, None, None), (u'price', <psycopg2._psycopg.type 'DECIMAL' at 0x10060a418>, None, None, None, None, None), (u'quantity', <psycopg2._psycopg.type 'INTEGER' at 0x10060a368>, None, None, None, None, None)]
  80
+  [(u'item_id', 23, None, None, None, None, None), (u'price', 1700, None, None, None, None, None), (u'quantity', 23, None, None, None, None, None)]
80 81
 
81 82
 We can also access all levels of ".description" in one step from the
82 83
 lead result, using the extension ".akiban_description".  This is
@@ -85,7 +86,7 @@ it produces 8-tuples, instead of 7-tuples.  The eighth member of the
85 86
 tuple contains the sub-description, if any::
86 87
 
87 88
   >>> cursor.akiban_description
88  
-  [(u'customer_id', <psycopg2._psycopg.type 'INTEGER' at 0x10068a3c0>, None, None, None, None, None, None), (u'name', <psycopg2._psycopg.type 'STRING' at 0x10068a520>, None, None, None, None, None, None), (u'orders', <object object at 0x1002af0c0>, None, None, None, None, None, [(u'order_id', <psycopg2._psycopg.type 'INTEGER' at 0x10068a3c0>, None, None, None, None, None, None), (u'order_info', <psycopg2._psycopg.type 'STRING' at 0x10068a520>, None, None, None, None, None, None), (u'items', <object object at 0x1002af0c0>, None, None, None, None, None, [(u'item_id', <psycopg2._psycopg.type 'INTEGER' at 0x10068a3c0>, None, None, None, None, None, None), (u'price', <psycopg2._psycopg.type 'DECIMAL' at 0x10068a470>, None, None, None, None, None, None), (u'quantity', <psycopg2._psycopg.type 'INTEGER' at 0x10068a3c0>, None, None, None, None, None, None)])])]
  89
+  [(u'customer_id', 23, None, None, None, None, None, None), (u'name', 1043, None, None, None, None, None, None), (u'orders', 5001, None, None, None, None, None, [(u'order_id', 23, None, None, None, None, None, None), (u'order_info', 1043, None, None, None, None, None, None), (u'items', 5001, None, None, None, None, None, [(u'item_id', 23, None, None, None, None, None, None), (u'price', 1700, None, None, None, None, None, None), (u'quantity', 23, None, None, None, None, None, None)])])]
89 90
 
90 91
 All those descriptions are nice, but how do we just get all those rows
91 92
 back?   We need to recursively descend through the nested cursors.
3  akiban/api.py
@@ -7,6 +7,9 @@ def __eq__(self, other):
7 7
     def __hash__(self):
8 8
         return hash(5001)
9 9
 
  10
+    def __repr__(self):
  11
+        return "<akiban.api.NESTED_CURSOR>"
  12
+
10 13
 NESTED_CURSOR = NestedCursorType()
11 14
 
12 15
 

0 notes on commit d13392b

Please sign in to comment.
Something went wrong with that request. Please try again.