Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 90a6785f6328bd27d307ce20202d6b34aa0cc10b authored by Ned Deily on 05 December 2017, 08:27:19 UTC
Bump to 3.7.0a3
Tip revision: 90a6785
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