代码如下:
Python Code
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# -*- coding: utf-8 -*- #!/usr/bin/python # filename: creat_db.py # codedtime: 2014-8-26 22:33:58 import sqlite3 #警告: todo.db文件被创建到当前目录下 con = sqlite3.connect( 'todo.db') con.execute( "CREATE TABLE todo (id INTEGER PRIMARY KEY, task char(100) NOT NULL, status bool NOT NULL)") con.execute( "INSERT INTO todo (task,status) VALUES\ ( 'Read A-byte-of-python to get a good introduction into Python', 0) ") con.execute( "INSERT INTO todo (task,status) VALUES\ ( 'Visit the Python website', 1) ") con.execute( "INSERT INTO todo (task,status) VALUES\ ( 'Test various editors for and check the syntax highlighting', 1) ") con.execute( "INSERT INTO todo (task,status) VALUES\ ( 'Choose your favorite WSGI-Framework', 0) ") con.commit() |