· 7 years ago · Feb 25, 2019, 09:50 PM
1with sqlite3.connect("BMS.db") as db:
2 cursor = db.cursor()
3 sql = """CREATE Table IF NOT EXISTS BookInformation(
4 BookID integer PRIMARY KEY AUTOINCREMENT,
5 bookName text,
6 Genre text,
7 DateReleased text,
8 ReadingLevel integer,
9 Barcode text,
10 Size integer,
11 ISBN text
12 ); """
13 cursor.execute(sql)
14
15 #FOR STUDENT INFOATION
16 sql = """CREATE Table IF NOT EXISTS StudentInformation(
17 StudentID integer PRIMARY KEY AUTOINCREMENT,
18 FirstName text,
19 SurName text,
20 Form text
21 ); """
22 cursor.execute(sql)
23
24 #FOR BOOK RENTING SERVICES
25 sql = """CREATE Table IF NOT EXISTS StudentBookInformation(
26 transactionID integer PRIMARY KEY AUTOINCREMENT,
27 BookID integer,
28 StudentID integer,
29 DateOUT text,
30 DateIN text,
31 returned boolean,
32 FOREIGN KEY (BookID) REFERENCES BookInformation(BookID),
33 FOREIGN KEY (StudentID) REFERENCES StudentInformation(StudentID)
34 ); """
35 cursor.execute(sql)