擅长:python、mysql、java
<p>你在用什么分机?对于<code>sqlite3</code>(以及与DB-API 2.0兼容的任何其他扩展),您可以使用类似于<a href="http://docs.python.org/library/sqlite3.html" rel="nofollow noreferrer">this</a>的东西:</p>
<pre><code>conn = sqlite3.connect('/tmp/example')
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 cursor if we are done with it
c.close()
</code></pre>
<p>顺便说一句,Python中没有<code>-></code></p>