summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-10-28 13:25:37 -0700
committerGitHub <noreply@github.com>2021-10-28 22:25:37 +0200
commitd6623c3ddb9a0e5ffed81253bd40f75c3c662f1a (patch)
tree8f78996680453cd67f7d0eb52ce50c3f27d97297
parent3767e0d94351653a34ba6a6914e57c5c231012b0 (diff)
downloadcpython-git-d6623c3ddb9a0e5ffed81253bd40f75c3c662f1a.tar.gz
bpo-45612: Add sqlite3 module docstring (GH-29224) (GH-29289)
(cherry picked from commit 4dd1e84789f0bd2da83ad06d23c569bf03713a50) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
-rw-r--r--Lib/sqlite3/__init__.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/sqlite3/__init__.py b/Lib/sqlite3/__init__.py
index 6c91df27cc..efdb7f2ba2 100644
--- a/Lib/sqlite3/__init__.py
+++ b/Lib/sqlite3/__init__.py
@@ -20,4 +20,38 @@
# 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@ghaering.de>.
+"""
+
from sqlite3.dbapi2 import *