· 6 years ago · Jan 13, 2020, 01:24 AM
1def CreateDefaultTables(self):
2 # Create the servers table
3 # |key | ServerName|
4 self.curser.execute( '''CREATE TABLE IF NOT EXISTS servers (
5 id_server INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
6 name TEXT NOT NULL UNIQUE)''')
7 # Create the Characters table
8 # |key | sharedServerNameKey | CharacterName|
9 self.curser.execute( '''CREATE TABLE IF NOT EXISTS charNames (
10 id_CharName INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
11 id_server INTEGER NOT NULL,
12 CharName TEXT NOT NULL UNIQUE,
13 FOREIGN KEY (id_server) REFERENCES servers (id_server))''')
14
15 # Create the Storage Location table
16 # |key | Location
17 # [Reincarnation Cache, Bank , Inventory]
18 #s
19 self.curser.execute( '''CREATE TABLE IF NOT EXISTS storageLoc (
20 id_StorageLoc INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
21 location TEXT NOT NULL)''')
22 # Create the Item table
23 # |key | sharedCharacterKey | sharedLocationKey | Item Name
24 self.curser.execute( '''CREATE TABLE IF NOT EXISTS items (
25 id_item INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
26 id_server INTEGER NOT NULL,
27 id_charName INTEGER NOT NULL,
28 id_StorageLoc INTEGER NOT NULL,
29 itemName TEXT NOT NULL,
30 FOREIGN KEY (id_CharName) REFERENCES charNames (id_CharName),
31 FOREIGN KEY (id_StorageLoc) REFERENCES storageLoc (id_StorageLoc),
32 FOREIGN KEY (id_Server) REFERENCES servers (id_Server))
33 ''' )
34
35 # Create the Items Type table
36 # |key | Type |
37 # [Potion,Scroll,Wand, reagent, Neck, Wrist, ect ect]
38 self.curser.execute( '''CREATE TABLE IF NOT EXISTS itemTypes (
39 id_itemType INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
40 type TEXT NOT NULL UNIQUE)''')
41 # Create Atributes Table
42 # |key | attribute |
43 # [glaciation,combustion ect ect]
44 self.curser.execute( '''CREATE TABLE IF NOT EXISTS attributes (
45 id_attribute INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
46 attribute TEXT NOT NULL UNIQUE)''')
47 # Create Items Table with Attributres
48 # |key | SharedItemKey | sharedLocationKey |sharedTypekey | SharedItemAttributeKey | AttributeValue
49 #
50 self.curser.execute( '''CREATE TABLE IF NOT EXISTS itemAtributes (
51 id_itemAttributes INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
52 id_item INTEGER NOT NULL,
53 id_itemType INTEGER NOT NULL,
54 id_attribute INTEGER NOT NULL,
55 itemAttributeValue TEXT,
56 FOREIGN KEY (id_item) REFERENCES items (id_item),
57 FOREIGN KEY (id_itemType) REFERENCES itemTypes (id_itemType),
58 FOREIGN KEY (id_attribute) REFERENCES attributes (id_attribute))
59 ''' )