Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Side by Side Diff: Doc/library/sqlite3.rst

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/socketserver.rst ('k') | Doc/library/ssl.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`sqlite3` --- DB-API 2.0 interface for SQLite databases 1 :mod:`sqlite3` --- DB-API 2.0 interface for SQLite databases
2 ============================================================ 2 ============================================================
3 3
4 .. module:: sqlite3 4 .. module:: sqlite3
5 :synopsis: A DB-API 2.0 implementation using SQLite 3.x. 5 :synopsis: A DB-API 2.0 implementation using SQLite 3.x.
6 .. sectionauthor:: Gerhard Häring <gh@ghaering.de> 6 .. sectionauthor:: Gerhard Häring <gh@ghaering.de>
7 7
8 8
9 SQLite is a C library that provides a lightweight disk-based database that 9 SQLite is a C library that provides a lightweight disk-based database that
10 doesn't require a separate server process and allows accessing the database 10 doesn't require a separate server process and allows accessing the database
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 If two :class:`Row` objects have exactly the same columns and their 608 If two :class:`Row` objects have exactly the same columns and their
609 members are equal, they compare equal. 609 members are equal, they compare equal.
610 610
611 .. method:: keys 611 .. method:: keys
612 612
613 This method returns a tuple of column names. Immediately after a query, 613 This method returns a tuple of column names. Immediately after a query,
614 it is the first member of each tuple in :attr:`Cursor.description`. 614 it is the first member of each tuple in :attr:`Cursor.description`.
615 615
616 Let's assume we initialize a table as in the example given above:: 616 Let's assume we initialize a table as in the example given above::
617 617
618 conn = sqlite3.connect(":memory:") 618 conn = sqlite3.connect(":memory:")
619 c = conn.cursor() 619 c = conn.cursor()
620 c.execute('''create table stocks 620 c.execute('''create table stocks
621 (date text, trans text, symbol text, 621 (date text, trans text, symbol text,
622 qty real, price real)''') 622 qty real, price real)''')
623 c.execute("""insert into stocks 623 c.execute("""insert into stocks
624 values ('2006-01-05','BUY','RHAT',100,35.14)""") 624 values ('2006-01-05','BUY','RHAT',100,35.14)""")
625 conn.commit() 625 conn.commit()
626 c.close() 626 c.close()
627 627
628 Now we plug :class:`Row` in:: 628 Now we plug :class:`Row` in::
629 629
630 >>> conn.row_factory = sqlite3.Row 630 >>> conn.row_factory = sqlite3.Row
631 >>> c = conn.cursor() 631 >>> c = conn.cursor()
632 >>> c.execute('select * from stocks') 632 >>> c.execute('select * from stocks')
633 <sqlite3.Cursor object at 0x7f4e7dd8fa80> 633 <sqlite3.Cursor object at 0x7f4e7dd8fa80>
634 >>> r = c.fetchone() 634 >>> r = c.fetchone()
635 >>> type(r) 635 >>> type(r)
636 <class 'sqlite3.Row'> 636 <class 'sqlite3.Row'>
637 >>> tuple(r) 637 >>> tuple(r)
638 ('2006-01-05', 'BUY', 'RHAT', 100.0, 35.14) 638 ('2006-01-05', 'BUY', 'RHAT', 100.0, 35.14)
639 >>> len(r) 639 >>> len(r)
640 5 640 5
641 >>> r[2] 641 >>> r[2]
642 'RHAT' 642 'RHAT'
643 >>> r.keys() 643 >>> r.keys()
644 ['date', 'trans', 'symbol', 'qty', 'price'] 644 ['date', 'trans', 'symbol', 'qty', 'price']
645 >>> r['qty'] 645 >>> r['qty']
646 100.0 646 100.0
647 >>> for member in r: 647 >>> for member in r:
648 ... print(member) 648 ... print(member)
649 ... 649 ...
650 2006-01-05 650 2006-01-05
651 BUY 651 BUY
652 RHAT 652 RHAT
653 100.0 653 100.0
654 35.14 654 35.14
655 655
656 656
657 .. _sqlite3-types: 657 .. _sqlite3-types:
658 658
659 SQLite and Python types 659 SQLite and Python types
660 ----------------------- 660 -----------------------
661 661
662 662
663 Introduction 663 Introduction
664 ^^^^^^^^^^^^ 664 ^^^^^^^^^^^^
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 Older SQLite versions had issues with sharing connections between threads. 895 Older SQLite versions had issues with sharing connections between threads.
896 That's why the Python module disallows sharing connections and cursors between 896 That's why the Python module disallows sharing connections and cursors between
897 threads. If you still try to do so, you will get an exception at runtime. 897 threads. If you still try to do so, you will get an exception at runtime.
898 898
899 The only exception is calling the :meth:`~Connection.interrupt` method, which 899 The only exception is calling the :meth:`~Connection.interrupt` method, which
900 only makes sense to call from a different thread. 900 only makes sense to call from a different thread.
901 901
902 .. rubric:: Footnotes 902 .. rubric:: Footnotes
903 903
904 .. [#f1] The sqlite3 module is not built with loadable extension support by 904 .. [#f1] The sqlite3 module is not built with loadable extension support by
905 default, because some platforms (notably Mac OS X) have SQLite 905 default, because some platforms (notably Mac OS X) have SQLite libraries which
906 libraries which are compiled without this feature. To get loadable 906 are compiled without this feature. To get loadable extension support, you must
907 extension support, you must pass --enable-loadable-sqlite-extensions to 907 pass --enable-loadable-sqlite-extensions to configure.
908 configure.
OLDNEW
« no previous file with comments | « Doc/library/socketserver.rst ('k') | Doc/library/ssl.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+