summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-07-29 08:44:29 (GMT)
committerGitHub <noreply@github.com>2022-07-29 08:44:29 (GMT)
commit2278dc74423565b3b9cc5c89804b5c7c947f2243 (patch)
tree8ea54c1816cb336215963d410bc6c3585f4a6aca /Doc
parentf59a5c53631d64cd45e98907c00ffd226675c864 (diff)
downloadcpython-2278dc74423565b3b9cc5c89804b5c7c947f2243.zip
cpython-2278dc74423565b3b9cc5c89804b5c7c947f2243.tar.gz
cpython-2278dc74423565b3b9cc5c89804b5c7c947f2243.tar.bz2
gh-95273: Condense sqlite3 executescript example (GH-95383) (#95419)
(cherry picked from commit e9c8de669d40d993489981be2973d1ea5bd10d0c) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/includes/sqlite3/executescript.py25
-rw-r--r--Doc/library/sqlite3.rst11
2 files changed, 9 insertions, 27 deletions
diff --git a/Doc/includes/sqlite3/executescript.py b/Doc/includes/sqlite3/executescript.py
deleted file mode 100644
index aea8943..0000000
--- 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 35dbb72..2b07b7c 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -813,9 +813,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()