-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate table and add data.py
108 lines (73 loc) · 2.91 KB
/
Create table and add data.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import sqlite3
conn = sqlite3.connect("tutorial.db")
c = conn.cursor()
##Create Students table
##def create_table():
## c.execute("CREATE TABLE IF NOT EXISTS Students(Name VARCHAR(20) NOT NULL,Surname VARCHAR(20) NOT NULL,Username VARCHAR(20) NOT NULL PRIMARY KEY UNIQUE, Classroom TEXT NOT NULL)")
##create_table()
##Create sensible dettail table
##def create_table1():
## c.execute("CREATE TABLE `Registration Sensible_Dettails` (`Username`VARCHAR(20) NOT NULL UNIQUE,`Password` TEXT NOT NULL,`Email`TEXT NOT NULL UNIQUE,PRIMARY KEY(`Username`)FOREIGN KEY (Username) REFERENCES Students(Username)")
##create_table1()
##Create Character Stats Table
##def create_table():
## c.execute("CREATE TABLE IF NOT EXISTS `Character_Stats`(`Username`VARCHAR(20) NOT NULL UNIQUE,`Health`INT NOT NULL,`ATK` INT NOT NULL,`DEF` INT NOT NULL,`AttackPotion` INT NOT NULL,`DefendPotion` INT NOT NULL, PRIMARY KEY(`Username`)FOREIGN KEY (Username) REFERENCES Students(Username))")
##create_table()
##Insert into students table
##def data_entry():
## c.execute("INSERT INTO Students VALUES('Simone','Apicella','xXOmegaXx','C35')")
## conn.commit()
## c.close()
## conn.close()
##data_entry()
##Insert into sensible data table
##def data_entry1():
## c.execute("INSERT INTO Sensible_Dettails VALUES('xxXOmegaXx','Omega3','[email protected]')")
## conn.commit()
## c.close()
## conn.close()
##data_entry1()
##Insert into Character Stats Table
##def data_entry():
## c.execute("INSERT INTO Character_Stats VALUES(`xXOmegaXx`,`100`,`20`,`5`,`1000`,`1000`)")
## conn.commit()
## c.close()
## conn.close()
##data_entry()
##Reading from Students table
c.execute('SELECT * FROM Students')
rows = c.fetchall()
for row in rows:
print('{0},{1},{2}'.format(row[0],row[1],row[2]))
conn.commit()
conn.close()
##def login():
## Username = input("Username:")
## c.execute('SELECT * FROM Sensible_Dettails WHERE Username = (?)',[Username])
## rows = c.fetchall()
## for row in rows:
## '{0},{1}'.format(row[0],row[1])
## Password = input("Password:")
## if Password == row[1]:
## print("GG")
## else:
## print("Username or Password")
##
##def register():
## Name = input("Name:")
## Surname = input("Surname:")
## Username = input("Username:")
## Classroom = input("Classroom:")
## Password = input("Password:")
## Passwordc = input("Repeat you password:")
## Email = input("Email:")
## if Password == Password1:
## c.execute ('INSERT INTO Sensible_Dettails VALUES(?,?,?)',(Username,Password,Email))
## c.execute ('INSERT INTO Students VALUES(?,?,?,?)',(Name,Surname,Username,Classroom))
## conn.commit()
## c.close()
## conn.close()
## else:
## print("Error")
## return register
##register()