~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to Doc/includes/sqlite3/createdb.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Not referenced from the documentation, but builds the database file the other
 
2
# code snippets expect.
 
3
 
 
4
import sqlite3
 
5
import os
 
6
 
 
7
DB_FILE = "mydb"
 
8
 
 
9
if os.path.exists(DB_FILE):
 
10
    os.remove(DB_FILE)
 
11
 
 
12
con = sqlite3.connect(DB_FILE)
 
13
cur = con.cursor()
 
14
cur.execute("""
 
15
        create table people
 
16
        (
 
17
          name_last      varchar(20),
 
18
          age            integer
 
19
        )
 
20
        """)
 
21
 
 
22
cur.execute("insert into people (name_last, age) values ('Yeltsin',   72)")
 
23
cur.execute("insert into people (name_last, age) values ('Putin',     51)")
 
24
 
 
25
con.commit()
 
26
 
 
27
cur.close()
 
28
con.close()