-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathhackbright_app.py
More file actions
36 lines (29 loc) · 835 Bytes
/
hackbright_app.py
File metadata and controls
36 lines (29 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sqlite3
DB = None
CONN = None
def get_student_by_github(github):
query = """SELECT first_name, last_name, github FROM Students WHERE github = ?"""
DB.execute(query, (github,))
row = DB.fetchone()
print """\
Student: %s %s
Github account: %s"""%(row[0], row[1], row[2])
def connect_to_db():
global DB, CONN
CONN = sqlite3.connect("hackbright.db")
DB = CONN.cursor()
def main():
connect_to_db()
command = None
while command != "quit":
input_string = raw_input("HBA Database> ")
tokens = input_string.split()
command = tokens[0]
args = tokens[1:]
if command == "student":
get_student_by_github(*args)
elif command == "new_student":
make_new_student(*args)
CONN.close()
if __name__ == "__main__":
main()