Skip to content
Snippets Groups Projects
Unverified Commit 2278dc74 authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub
Browse files

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


(cherry picked from commit e9c8de66)

Co-authored-by: default avatarErlend Egeberg Aasland <erlend.aasland@innova.no>
parent f59a5c53
Branches
Tags
No related merge requests found
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()
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment