使用Python操作SQLite 2016-11-18 10:00

示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/usr/bin/python

import sqlite3

conn = sqlite3.connect('blog.db')

print "Opened database successfully";

cursor = conn.execute("SELECT title FROM posts")

for row in cursor:
    print "title: ", row[0]

print "Operation done successfully";
conn.close()

参考文档

  1. SQLite - Python
Tags: #Python    Post on Programming