您无需安装任何东西即可在 python 上使用 sqlite3。
关于 sqlite:https://www.sqlite.org/about.html
如果您有使用数据库的经验,
你可以认为 sqlite3 是一个类似于数据库包含表的文件。
因为python支持sqlite3,所以可以新建一个sqlite3文件。
此示例仅使用 python 创建一个新的 example.db 文件,如果不存在。
import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()
# Create table
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')
# Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
# Save (commit) the changes
conn.commit()
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
阅读此文档:https://docs.python.org/2/library/sqlite3.html
但我建议您安装 sqlite 以使用 SQLite 的命令行 Shell。
$ sqlite3 ex1
SQLite version 3.8.5 2014-05-29 12:36:14
Enter ".help" for usage hints.
sqlite> create table tbl1(one varchar(10), two smallint);
sqlite> insert into tbl1 values('hello!',10);
sqlite> insert into tbl1 values('goodbye', 20);
sqlite> select * from tbl1;
hello!|10
goodbye|20
sqlite>