-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableCreationExample.py
More file actions
27 lines (19 loc) · 1.27 KB
/
TableCreationExample.py
File metadata and controls
27 lines (19 loc) · 1.27 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
from sqlinterface import *
import sqlinterface
def main():
sqlinterface.printDebugMessage = True
db = DataBase("crosscountry.db")
# Table holds the name of the table and then a dictionary containing the value name and type
userTable = Table("Users", {"UserCode" : VarChar(10), "LastName" : VarChar(25), "House" : VarChar(10), "Role" : VarChar(10), "YearLevel" : Int(), "DOB" : VarChar(8), "FirstName" : VarChar(20)})
# Passing the table into the actual database will create it in SQL
# NOTE: If the table already exists in python this won't do anything
db.createTable(userTable)
AgeLevelTable = Table("AgeLevel", {"AgeLevel" : VarChar(10), "UserCode" : VarChar(10)})
db.createTable(AgeLevelTable)
AgeLevelEventTable = Table("AgeLevelEvent", {"AgeLevel" : VarChar(10), "UserCode" : VarChar(10), "EventName" : VarChar(20)})
db.createTable(AgeLevelEventTable)
AgeLevelEventPlaceTable = Table("AgeLevelEventPlace", {"AgeLevel" : VarChar(10), "UserCode" : VarChar(10), "EventName" : VarChar(20), "Time" : VarChar(6), "Place" : Int(), "Points" : Int()})
db.createTable(AgeLevelEventPlaceTable)
db.insertIntoTable(userTable, ["s624881", "McCarney", "Morgan", "Student", "2024", "testdate", "Dallas"])
if __name__ == '__main__':
main()