-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel.py
More file actions
60 lines (44 loc) · 1.59 KB
/
model.py
File metadata and controls
60 lines (44 loc) · 1.59 KB
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
59
import sqlite3
from kivy.uix.label import Label
from kivy.uix.popup import Popup
conn = sqlite3.connect('student_db.db')
def create_table():
try:
# conn.execute("DROP TABLE IF EXISTS students")
conn.execute("CREATE TABLE students"
"("
" first_name VARCHAR(22),"
" last_name VARCHAR(22),"
" student_id CHAR(8) PRIMARY KEY,"
" phone INTEGER,"
" parent_address VARCHAR(30),"
" sex CHAR(1)"
")"
)
conn.commit()
conn.execute("CREATE TABLE admin"
"("
" name VARCHAR(30),"
" password VARCHAR(230)"
")"
)
conn.commit()
except sqlite3.OperationalError as exc:
print exc.message
def insert(f_name, l_name, std_id, phone, address, sex):
try:
conn.execute("INSERT INTO students "
" (first_name,last_name,student_id,phone,parent_address,sex)"
" VALUES "
" (?,?,?,?,?,?)",
(f_name, l_name, std_id, phone, address, sex))
conn.commit()
except sqlite3.OperationalError as exc:
Popup(conttent=Label(text=str(exc.message)), size_hint=(None, None), size=(200, 200)).open()
"""conn.execute("INSERT INTO admin "
"( name,password)"
" VALUES "
"(?,?)",
("admin","password"))
conn.commit()
"""