Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.9] bpo-45612: Add sqlite3 module docstring (GH-29224) #29289

Merged
merged 1 commit into from
Oct 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Lib/sqlite3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *