8000 bpo-45612: Add sqlite3 module docstring (GH-29224) (GH-29288) · python/cpython@823b3e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 823b3e3

Browse files
miss-islingtonErlend Egeberg Aasland
andauthored
bpo-45612: Add sqlite3 module docstring (GH-29224) (GH-29288)
(cherry picked from commit 4dd1e84) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
1 parent fef54ab commit 823b3e3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Lib/sqlite3/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
8000
@@ -20,6 +20,40 @@
2020
# misrepresented as being the original software.
2121
# 3. This notice may not be removed or altered from any source distribution.
2222

23+
"""
24+
The sqlite3 extension module provides a DB-API 2.0 (PEP 249) compilant
25+
interface to the SQLite library, and requires SQLite 3.7.15 or newer.
26+
27+
To use the module, you must first create a database Connection object:
28+
29+
import sqlite3
30+
cx = sqlite3.connect("test.db") # test.db will be created or opened
31+
32+
You can also use the special database name ":memory:" to connect to a transient
33+
in-memory database:
34+
35+
cx = sqlite3.connect(":memory:") # connect to a database in RAM
36+
37+
Once you have a Connection object, you can create a Cursor object and call its
38+
execute() method to perform SQL queries:
39+
40+
cu = cx.cursor()
41+
42+
# create a table
43+
cu.execute("create table lang(name, first_appeared)")
44+
45+
# insert values into a table
46+
cu.execute("insert into lang values (?, ?)", ("C", 1972))
47+
48+
# execute a query and iterate over the result
49+
for row in cu.execute("select * from lang"):
50+
print(row)
51+
52+
cx.close()
53+
54+
The sqlite3 module is written by Gerhard Häring <gh@ghaering.de>.
55+
"""
56+
2357
from sqlite3.dbapi2 import *
2458

2559

0 commit comments

Comments
 (0)
0