mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
Further integration of the documentation for the sqlite3 module. There's still
quite some content to move over from the pysqlite manual, but it's a start now.
This commit is contained in:
parent
e3c958c33b
commit
82560ebb8d
30 changed files with 654 additions and 3 deletions
28
Doc/lib/sqlite3/createdb.py
Normal file
28
Doc/lib/sqlite3/createdb.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Not referenced from the documentation, but builds the database file the other
|
||||
# code snippets expect.
|
||||
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
DB_FILE = "mydb"
|
||||
|
||||
if os.path.exists(DB_FILE):
|
||||
os.remove(DB_FILE)
|
||||
|
||||
con = sqlite3.connect(DB_FILE)
|
||||
cur = con.cursor()
|
||||
cur.execute("""
|
||||
create table people
|
||||
(
|
||||
name_last varchar(20),
|
||||
age integer
|
||||
)
|
||||
""")
|
||||
|
||||
cur.execute("insert into people (name_last, age) values ('Yeltsin', 72)")
|
||||
cur.execute("insert into people (name_last, age) values ('Putin', 51)")
|
||||
|
||||
con.commit()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
Loading…
Add table
Add a link
Reference in a new issue