gh-95273: Condense sqlite3 executescript example (#95383)

This commit is contained in:
Erlend Egeberg Aasland 2022-07-29 09:40:44 +02:00 committed by GitHub
parent 3e7cad3bca
commit e9c8de669d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 27 deletions

View File

@ -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()

View File

@ -1007,9 +1007,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()