Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 3f568389763c205f8779ad75f2cf44ab9782608e authored by Larry Hastings on 07 August 2017, 07:59:11 UTC
Version bump for 3.5.4 final.
Tip revision: 3f56838
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