import sqlite3 db = sqlite3.connect('database.db')
c = db.cursor() c.execute('create table portfolio (symbol text, shares integer, price real)') <sqlite3.Cursor object at 0x10067a730> db.commit()
<sqlite3.Cursor object at 0x10067a730>
db.commit()
for row in db.execute('select * from portfolio'): ... print(row) ... ('GOOG', 100, 490.1) ('AAPL', 50, 545.75) ('FB', 150, 7.45) ('HPQ', 75, 33.2)
min_price = 100 for row in db.execute('select * from portfolio where price >= ?', (min_price,)): ... print(row) ... ('GOOG', 100, 490.1) ('AAPL', 50, 545.75)