Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Minor improvements #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions clip/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def fetch_class_instances(self):
'institution': instance[6]
})
finally:
self.lock.acquire()
self.lock.release()
return class_instances

def commit(self):
Expand All @@ -550,16 +550,12 @@ def commit(self):
self.lock.release()

def find_student(self, name):
nice_try = escape(name)
query_string = '%'
for word in nice_try.split():
query_string += (word + '%')

query_string = "%{0}%".format("%".join(name.split()))
self.lock.acquire()
try:
self.cursor.execute("SELECT internal_id, name, abbreviation "
"FROM Students "
"WHERE name LIKE '{}'".format(query_string))
"WHERE name LIKE '?'", (query_string, ))
return set(self.cursor.fetchall())
finally:
self.lock.release()
self.lock.release()