<p>在python上使用sqlite3不需要安装任何东西。</p>
<p>关于sqlite:<a href="https://www.sqlite.org/about.html" rel="nofollow">https://www.sqlite.org/about.html</a></p>
<p>如果你有使用数据库的经验,
您可以认为sqlite3是一个类似于数据库包含表的文件。</p>
<p>因为python支持sqlite3,所以可以创建一个新的sqlite3文件。</p>
<p>此示例创建一个新的example.db文件(如果不存在,则仅使用python)。</p>
<pre><code>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()
</code></pre>
<p>阅读此文档:<a href="https://docs.python.org/2/library/sqlite3.html" rel="nofollow">https://docs.python.org/2/library/sqlite3.html</a></p>
<p>但我建议您安装sqlite,以便对sqlite使用命令行Shell。</p>
<pre><code>$ 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>
</code></pre>