@@ -495,6 +495,43 @@ Connection objects
495
495
496
496
.. versionadded :: 3.2
497
497
498
+ .. attribute :: row_factory
499
+
500
+ A callable that accepts two arguments,
501
+ a :class: `Cursor ` object and the raw row results as a :class: `tuple `,
502
+ and returns a custom object representing an SQLite row.
503
+
504
+ Example:
505
+
506
+ .. literalinclude :: ../includes/sqlite3/row_factory.py
507
+
508
+ If returning a tuple doesn't suffice and you want name-based access to
509
+ columns, you should consider setting :attr: `row_factory ` to the
510
+ highly optimized :class: `sqlite3.Row ` type. :class: `Row ` provides both
511
+ index-based and case-insensitive name-based access to columns with almost no
512
+ memory overhead. It will probably be better than your own custom
513
+ dictionary-based approach or even a db_row based solution.
514
+
515
+ .. XXX what's a db_row-based solution?
516
+
517
+ .. attribute :: text_factory
518
+
519
+ A callable that accepts a :class: `bytes ` parameter and returns a text
520
+ representation of it.
521
+ The callable is invoked for SQLite values with the ``TEXT `` data type.
522
+ By default, this attribute is set to :class: `str `.
523
+ If you want to return ``bytes `` instead, set *text_factory * to ``bytes ``.
524
+
525
+ Example:
526
+
527
+ .. literalinclude :: ../includes/sqlite3/text_factory.py
528
+
529
+ .. attribute :: total_changes
530
+
531
+ Return the total number of database rows that have been modified, inserted, or
532
+ deleted since the database connection was opened.
533
+
534
+
498
535
.. method :: cursor(factory=Cursor)
499
536
500
537
Create and return a :class: `Cursor ` object.
@@ -724,45 +761,6 @@ Connection objects
724
761
.. versionchanged :: 3.10
725
762
Added the ``sqlite3.load_extension `` auditing event.
726
763
727
- .. attribute :: row_factory
728
-
729
- A callable that accepts two arguments,
730
- a :class: `Cursor ` object and the raw row results as a :class: `tuple `,
731
- and returns a custom object representing an SQLite row.
732
-
733
- Example:
734
-
735
- .. literalinclude :: ../includes/sqlite3/row_factory.py
736
-
737
- If returning a tuple doesn't suffice and you want name-based access to
738
- columns, you should consider setting :attr: `row_factory ` to the
739
- highly optimized :class: `sqlite3.Row ` type. :class: `Row ` provides both
740
- index-based and case-insensitive name-based access to columns with almost no
741
- memory overhead. It will probably be better than your own custom
742
- dictionary-based approach or even a db_row based solution.
743
-
744
- .. XXX what's a db_row-based solution?
745
-
746
-
747
- .. attribute :: text_factory
748
-
749
- A callable that accepts a :class: `bytes ` parameter and returns a text
750
- representation of it.
751
- The callable is invoked for SQLite values with the ``TEXT `` data type.
752
- By default, this attribute is set to :class: `str `.
753
- If you want to return ``bytes `` instead, set *text_factory * to ``bytes ``.
754
-
755
- Example:
756
-
757
- .. literalinclude :: ../includes/sqlite3/text_factory.py
758
-
759
-
760
- .. attribute :: total_changes
761
-
762
- Return the total number of database rows that have been modified, inserted, or
763
- deleted since the database connection was opened.
764
-
765
-
766
764
.. method :: iterdump
767
765
768
766
Return an :term: `iterator ` to dump the database as SQL source code.
0 commit comments