@@ -532,6 +532,43 @@ Connection objects
532
532
533
533
.. versionadded :: 3.2
534
534
535
+ .. attribute :: row_factory
536
+
537
+ A callable that accepts two arguments,
538
+ a :class: `Cursor ` object and the raw row results as a :class: `tuple `,
539
+ and returns a custom object representing an SQLite row.
540
+
541
+ Example:
542
+
543
+ .. literalinclude :: ../includes/sqlite3/row_factory.py
544
+
545
+ If returning a tuple doesn't suffice and you want name-based access to
546
+ columns, you should consider setting :attr: `row_factory ` to the
547
+ highly optimized :class: `sqlite3.Row ` type. :class: `Row ` provides both
548
+ index-based and case-insensitive name-based access to columns with almost no
549
+ memory overhead. It will probably be better than your own custom
550
+ dictionary-based approach or even a db_row based solution.
551
+
552
+ .. XXX what's a db_row-based solution?
553
+
554
+ .. attribute :: text_factory
555
+
556
+ A callable that accepts a :class: `bytes ` parameter and returns a text
557
+ representation of it.
558
+ The callable is invoked for SQLite values with the ``TEXT `` data type.
559
+ By default, this attribute is set to :class: `str `.
560
+ If you want to return ``bytes `` instead, set *text_factory * to ``bytes ``.
561
+
562
+ Example:
563
+
564
+ .. literalinclude :: ../includes/sqlite3/text_factory.py
565
+
566
+ .. attribute :: total_changes
567
+
568
+ Return the total number of database rows that have been modified, inserted, or
569
+ deleted since the database connection was opened.
570
+
571
+
535
572
.. method :: cursor(factory=Cursor)
536
573
537
574
Create and return a :class: `Cursor ` object.
@@ -843,45 +880,6 @@ Connection objects
843
880
.. versionchanged :: 3.10
844
881
Added the ``sqlite3.load_extension `` auditing event.
845
882
846
- .. attribute :: row_factory
847
-
848
- A callable that accepts two arguments,
849
- a :class: `Cursor ` object and the raw row results as a :class: `tuple `,
850
- and returns a custom object representing an SQLite row.
851
-
852
- Example:
853
-
854
- .. literalinclude :: ../includes/sqlite3/row_factory.py
855
-
856
- If returning a tuple doesn't suffice and you want name-based access to
857
- columns, you should consider setting :attr: `row_factory ` to the
858
- highly optimized :class: `sqlite3.Row ` type. :class: `Row ` provides both
859
- index-based and case-insensitive name-based access to columns with almost no
860
- memory overhead. It will probably be better than your own custom
861
- dictionary-based approach or even a db_row based solution.
862
-
863
- .. XXX what's a db_row-based solution?
864
-
865
-
866
- .. attribute :: text_factory
867
-
868
- A callable that accepts a :class: `bytes ` parameter and returns a text
869
- representation of it.
870
- The callable is invoked for SQLite values with the ``TEXT `` data type.
871
- By default, this attribute is set to :class: `str `.
872
- If you want to return ``bytes `` instead, set *text_factory * to ``bytes ``.
873
-
874
- Example:
875
-
876
- .. literalinclude :: ../includes/sqlite3/text_factory.py
877
-
878
-
879
- .. attribute :: total_changes
880
-
881
- Return the total number of database rows that have been modified, inserted, or
882
- deleted since the database connection was opened.
883
-
884
-
885
883
.. method :: iterdump
886
884
887
885
Return an :term: `iterator ` to dump the database as SQL source code.
0 commit comments