Skip to content

Commit 5c800b3

Browse files
author
Pat East
committed
Add indexes to database
1 parent 0e200a5 commit 5c800b3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dbhelper.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ def __init__(self, dbname="todo.sqlite"):
66
self.conn = sqlite3.connect(dbname)
77

88
def setup(self):
9-
stmt = "CREATE TABLE IF NOT EXISTS items (description text, owner text)"
10-
self.conn.execute(stmt)
9+
tblstmt = "CREATE TABLE IF NOT EXISTS items (description text, owner text)"
10+
itemidx = "CREATE INDEX IF NOT EXISTS itemIndex ON items (description ASC)"
11+
ownidx = "CREATE INDEX IF NOT EXISTS ownIndex ON items (owner ASC)"
12+
self.conn.execute(tblstmt)
13+
self.conn.execute(itemidx)
14+
self.conn.execute(ownidx)
1115
self.conn.commit()
1216

1317
def add_item(self, item_text, owner):

0 commit comments

Comments
 (0)