[Python-checkins] bpo-45612: Add sqlite3 module docstring (GH-29224) (GH-29288)

ambv webhook-mailer at python.org
Thu Oct 28 16:25:02 EDT 2021


https://github.com/python/cpython/commit/823b3e39ae12884d5aa3c98341a41b2d6f19d329
commit: 823b3e39ae12884d5aa3c98341a41b2d6f19d329
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2021-10-28T22:24:52+02:00
summary:

bpo-45612: Add sqlite3 module docstring (GH-29224) (GH-29288)

(cherry picked from commit 4dd1e84789f0bd2da83ad06d23c569bf03713a50)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland at innova.no>

files:
M Lib/sqlite3/__init__.py

diff --git a/Lib/sqlite3/__init__.py b/Lib/sqlite3/__init__.py
index f001c0678e195..edc58f15b25ce 100644
--- a/Lib/sqlite3/__init__.py
+++ b/Lib/sqlite3/__init__.py
@@ -20,6 +20,40 @@
 #    misrepresented as being the original software.
 # 3. This notice may not be removed or altered from any source distribution.
 
+"""
+The sqlite3 extension module provides a DB-API 2.0 (PEP 249) compilant
+interface to the SQLite library, and requires SQLite 3.7.15 or newer.
+
+To use the module, you must first create a database Connection object:
+
+    import sqlite3
+    cx = sqlite3.connect("test.db")  # test.db will be created or opened
+
+You can also use the special database name ":memory:" to connect to a transient
+in-memory database:
+
+    cx = sqlite3.connect(":memory:")  # connect to a database in RAM
+
+Once you have a Connection object, you can create a Cursor object and call its
+execute() method to perform SQL queries:
+
+    cu = cx.cursor()
+
+    # create a table
+    cu.execute("create table lang(name, first_appeared)")
+
+    # insert values into a table
+    cu.execute("insert into lang values (?, ?)", ("C", 1972))
+
+    # execute a query and iterate over the result
+    for row in cu.execute("select * from lang"):
+        print(row)
+
+    cx.close()
+
+The sqlite3 module is written by Gerhard Häring <gh at ghaering.de>.
+"""
+
 from sqlite3.dbapi2 import *
 
 



More information about the Python-checkins mailing list