From f4f1042b2e6338fc880c289d56cade17a687a0ab Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 28 Jul 2022 15:31:47 +0200 Subject: [PATCH 1/2] gh-95273: Condense sqlite3 executescript example --- Doc/includes/sqlite3/executescript.py | 25 ------------------------- Doc/library/sqlite3.rst | 10 ++++++++-- 2 files changed, 8 insertions(+), 27 deletions(-) delete mode 100644 Doc/includes/sqlite3/executescript.py diff --git a/Doc/includes/sqlite3/executescript.py b/Doc/includes/sqlite3/executescript.py deleted file mode 100644 index aea8943fbee598..00000000000000 --- 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 d493f5fd95631d..07216078aaf842 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1007,9 +1007,15 @@ Cursor Objects *sql_script* must be a :class:`string `. - Example: + Example:: - .. literalinclude:: ../includes/sqlite3/executescript.py + cur.executescript(""" + begin; + create table person(firstname, lastname, age); + create table book(title, author, published); + create table publisher(name, address); + commit; + """) .. method:: fetchone() From e81e2e1b629bb58b74fc89fe4a38f9722f2c7155 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Fri, 29 Jul 2022 09:28:26 +0200 Subject: [PATCH 2/2] Update Doc/library/sqlite3.rst --- Doc/library/sqlite3.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 07216078aaf842..faa53f4dbcf59f 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1009,6 +1009,7 @@ Cursor Objects Example:: + # cur is an sqlite3.Cursor object cur.executescript(""" begin; create table person(firstname, lastname, age);