Created
February 10, 2015 19:36
-
-
Save dmaynor/1f54e539e5efa237faae to your computer and use it in GitHub Desktop.
python sqlite snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment