[Python-checkins] gh-95273: Condense sqlite3 executescript example (GH-95383)
miss-islington
webhook-mailer at python.org
Fri Jul 29 03:49:02 EDT 2022
https://github.com/python/cpython/commit/6eae15abb6983f644728e86141e6486c85fe8850
commit: 6eae15abb6983f644728e86141e6486c85fe8850
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-07-29T00:48:47-07:00
summary:
gh-95273: Condense sqlite3 executescript example (GH-95383)
(cherry picked from commit e9c8de669d40d993489981be2973d1ea5bd10d0c)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland at innova.no>
files:
D Doc/includes/sqlite3/executescript.py
M Doc/library/sqlite3.rst
diff --git a/Doc/includes/sqlite3/executescript.py b/Doc/includes/sqlite3/executescript.py
deleted file mode 100644
index aea8943fbee59..0000000000000
--- a/Doc/includes/sqlite3/executescript.py
+++ /dev/null
@@ -1,25 +0,0 @@
-import sqlite3
-
-con = sqlite3.connect(":memory:")
-cur = con.cursor()
-cur.executescript("""
- create table person(
- firstname,
- lastname,
- age
- );
-
- create table book(
- title,
- author,
- published
- );
-
- insert into book(title, author, published)
- values (
- 'Dirk Gently''s Holistic Detective Agency',
- 'Douglas Adams',
- 1987
- );
- """)
-con.close()
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 633b78453feb9..e6b0714f27055 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -997,9 +997,16 @@ Cursor Objects
*sql_script* must be a :class:`string <str>`.
- Example:
+ Example::
- .. literalinclude:: ../includes/sqlite3/executescript.py
+ # cur is an sqlite3.Cursor object
+ cur.executescript("""
+ begin;
+ create table person(firstname, lastname, age);
+ create table book(title, author, published);
+ create table publisher(name, address);
+ commit;
+ """)
.. method:: fetchone()
More information about the Python-checkins
mailing list