Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 4893861ab58544091feab2946648245ac1271e2f authored by Ned Deily on 13 October 2018, 07:01:32 UTC
3.6.7rc2
Tip revision: 4893861
createdb.py
# 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()
back to top