-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestSQL.py
58 lines (47 loc) · 1.62 KB
/
testSQL.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sqlite3
def ConnectDataBase():
conn = sqlite3.connect('/Users/Han/Documents/CS 4980 Child-Computer Interaction(2018 FALL)/Child_Computer_Interaction_Project/AppData.db')
print("Opened database successfully")
conn.close()
def CreateChoreTable():
conn = sqlite3.connect('/Users/Han/Documents/CS 4980 Child-Computer Interaction(2018 FALL)/Child_Computer_Interaction_Project/AppData.db')
conn.execute('''CREATE TABLE if not exists Kids
(name text, time text)''')
print ("Table created successfully")
conn.close()
def InsertNewKid():
conn = sqlite3.connect('AppData.db')
# Kids_sql = "INSERT INTO Kids (name,age) VALUES (?,?)"
with conn:
cur = conn.cursor()
cur.execute("INSERT INTO Kids VALUES ('Colin','9')")
cur.execute("INSERT INTO Kids VALUES ('Peter','11')")
cur.execute("INSERT INTO Kids VALUES ('Jim','12')")
#print("Successfully insert "+ name + " into Kids Table")
conn.close()
def where():
num = "1"
conn = sqlite3.connect('AppData.db')
with conn:
cur = conn.cursor()
cur.execute('''SELECT number FROM Chore''')
rows = cur.fetchall()
numberList = []
for row in rows:
numberList.append(row[0])
print(numberList)
if num in numberList:
print("yes")
'''
def get():
conn = sqlite3.connect('AppData.db')
with conn:
cur = conn.cursor()
cur.execute("SELECT name from Kids")
rows = cur.fetchall()
for row in rows:
print(row[0])'''
ConnectDataBase()
CreateChoreTable()
#InsertNewKid()
where()