added more to the database

This commit is contained in:
0ceanSlim 2023-09-05 22:59:56 -04:00
parent ac1c9bd30e
commit 95c30fb875
11 changed files with 151 additions and 18 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.analysis.typeCheckingMode": "off"
}

View File

@ -3,7 +3,6 @@ import os
import csv
# Function to determine the data type of a value
def get_data_type(value):
try:
int(value)
@ -16,26 +15,45 @@ def get_data_type(value):
return "TEXT"
# Connect to the SQLite database
conn = sqlite3.connect("items.db")
# Connect to the SQLite database and delete existing tables
conn = sqlite3.connect("database.db")
cursor = conn.cursor()
# Get a list of CSV files in the "data" directory
data_dir = "data" # Change this to your data directory path
csv_files = [f for f in os.listdir(data_dir) if f.endswith(".csv")]
# Iterate through CSV files and create tables
for csv_file in csv_files:
table_name = os.path.splitext(csv_file)[
0
] # Remove the file extension to get the table name
# Drop all existing tables except for sqlite_sequence
cursor.execute("PRAGMA foreign_keys = OFF;")
cursor.execute(
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_sequence';"
)
existing_tables = cursor.fetchall()
for table in existing_tables:
cursor.execute(f"DROP TABLE IF EXISTS {table[0]};")
# Read the first row of the CSV file to determine the column names and data types
# Commit the changes to delete existing tables
conn.commit()
# Iterate through CSV files and create new tables
for csv_file in csv_files:
table_name = os.path.splitext(csv_file)[0]
# Read the first row of the CSV file to determine the column names
with open(os.path.join(data_dir, csv_file), newline="") as csvfile:
csv_reader = csv.reader(csvfile)
header = next(csv_reader)
data_types = [get_data_type(value) for value in header]
# Read the second row to determine data types
with open(os.path.join(data_dir, csv_file), newline="") as csvfile:
csv_reader = csv.reader(csvfile)
next(csv_reader) # Skip the header row
data_row = next(csv_reader)
data_types = [get_data_type(value) for value in data_row]
# Add a primary key column if needed (replace 'unique_id' with your unique identifier column name)
if "unique_id" in header:
header[header.index("unique_id")] += " PRIMARY KEY"
# Generate the CREATE TABLE statement dynamically based on the column names and data types
create_table_sql = f"CREATE TABLE IF NOT EXISTS {table_name} (\n"
@ -46,6 +64,15 @@ for csv_file in csv_files:
# Execute the CREATE TABLE statement
cursor.execute(create_table_sql)
# Read and insert data from the CSV file into the table
with open(os.path.join(data_dir, csv_file), newline="") as csvfile:
csv_reader = csv.reader(csvfile)
next(csv_reader) # Skip the header row
for row in csv_reader:
placeholders = ",".join(["?"] * len(row))
insert_sql = f"INSERT INTO {table_name} VALUES ({placeholders});"
cursor.execute(insert_sql, row)
# Commit the changes and close the connection
conn.commit()
conn.close()

51
Database/data/gear.csv Normal file
View File

@ -0,0 +1,51 @@
id,type,name,rarity,weight,height,width,stack,value,storage,plate
NULL,rig,Hunting Vest,1,0.25,3,2,1,120000,6,NULL
NULL,rig,Micro Chest Rig,1,0.30,2,3,1,140000,8,NULL
NULL,rig,Minimalist Harness,1,1.00,3,3,1,160000,10,NULL
NULL,rig,Chest Rig,2,0.70,3,4,1,180000,12,NULL
NULL,rig,Heavy Vest,2,0.90,3,4,1,200000,14,NULL
NULL,rig,Heavy Chest Rig,2,0.35,4,3,1,250000,16,NULL
NULL,rig,Belt Rig,3,0.80,4,3,1,300000,18,NULL
NULL,rig,Load Bearing Rig,3,1.00,4,4,1,350000,20,NULL
NULL,rig,High Capacity Rig,4,0.65,3,4,1,400000,24,NULL
NULL,rigArmor,Damaged Plate Carrier,2,4.50,3,3,1,250000,10,1
NULL,rigArmor,Basic Plate Carrier,2,4.20,4,3,1,270000,12,1
NULL,rigArmor,Precision Plate Carrier,3,5.90,4,3,1,300000,14,1
NULL,rigArmor,Upgraded Plate Carrier,3,6.45,3,4,1,350000,17,1
NULL,rigArmor,Multi Mission Plate Carrier,4,7.30,3,4,1,400000,18,1
NULL,rigArmor,Arma Plate Carrier,4,8.15,4,4,1,450000,19,1
NULL,rigArmor,Armored Plate Carrier,4,9.00,4,4,1,475000,20,1
NULL,rigArmor,Ranger Plate Carrier,5,9.55,4,3,1,550000,23,1
NULL,rigArmor,Assault Rig,5,12.40,3,4,1,580000,24,1
NULL,rigArmor,Armored Vest,5,14.25,4,4,1,600000,25,1
NULL,pack,Drawstring Bag,1,1.10,3,2,1,50000,6,NULL
NULL,pack,Duffle Bag,1,2.12,2,4,1,80000,8,NULL
NULL,pack,Sling Bag,1,1.85,3,3,1,100000,9,NULL
NULL,pack,Rucksack,2,2.50,4,3,1,140000,12,NULL
NULL,pack,Mini Bag,2,2.38,3,4,1,150000,12,NULL
NULL,pack,Tourist Backpack,2,2.25,5,3,1,220000,15,NULL
NULL,pack,Standard Backpack,2,1.80,4,4,1,250000,16,NULL
NULL,pack,Tactical Backpack,3,2.00,5,4,1,400000,20,NULL
NULL,pack,Takedown Backpack,3,2.50,7,3,1,500000,31,NULL
NULL,pack,Battle Backpack,3,3.00,5,5,1,600000,25,NULL
NULL,pack,Hiking Backpack,4,4.00,6,5,1,750000,30,NULL
NULL,pack,Assault Backpack,4,6.00,7,5,1,1000000,35,NULL
NULL,pack,Raid Backpack,5,8.00,8,5,1,1500000,40,NULL
NULL,ears,Peltor Comtacs,2,1.54,2,2,1,NULL,NULL,NULL
NULL,ears,Walker's Razor,2,0.95,2,2,1,NULL,NULL,NULL
NULL,helmet,Steel Helmet (2),2,3.31,2,2,1,450000,NULL,NULL
NULL,helmet,Motorcycle Helmet (1),1,4.19,2,2,1,120000,NULL,NULL
NULL,helmet,Airsoft Replica Helmet (1),2,1.00,2,2,1,200000,NULL,NULL
NULL,helmet,Military Helmet Class 4 High Cut,2,4.19,2,2,1,850000,NULL,NULL
NULL,helmet,Military Helmet Class 4 Full,3,4.19,2,2,1,900000,NULL,NULL
NULL,helmet,Military Helmet Class 4+ High Cut,3,4.19,2,2,1,1125000,NULL,NULL
NULL,helmet,Military Helmet Class 4+ Full,4,4.19,2,2,1,1350000,NULL,NULL
NULL,armor,Light Body Armor (3),2,7.72,3,3,1,1370000,NULL,NULL
NULL,armor,Bullet Proof Vest (4),3,11.46,3,3,1,1658000,NULL,NULL
NULL,plate,Class III Plate,2,5.00,3,3,1,1185000,NULL,NULL
NULL,plate,Class IV Plate,3,6.00,3,3,1,1480000,NULL,NULL
NULL,plate,Class IV+ Plate,4,7.00,3,3,1,1850000,NULL,NULL
NULL,pouch,Pouch 1x1,1,0.15,1,1,1,25000,NULL,NULL
NULL,pouch,Pouch 2x1,2,0.30,1,2,1,60000,NULL,NULL
NULL,pouch,Pouch 3x1,3,0.45,1,3,1,130000,NULL,NULL
NULL,pouch,Pouch 2x2,4,0.60,2,2,1,300000,NULL,NULL
1 id type name rarity weight height width stack value storage plate
2 NULL rig Hunting Vest 1 0.25 3 2 1 120000 6 NULL
3 NULL rig Micro Chest Rig 1 0.30 2 3 1 140000 8 NULL
4 NULL rig Minimalist Harness 1 1.00 3 3 1 160000 10 NULL
5 NULL rig Chest Rig 2 0.70 3 4 1 180000 12 NULL
6 NULL rig Heavy Vest 2 0.90 3 4 1 200000 14 NULL
7 NULL rig Heavy Chest Rig 2 0.35 4 3 1 250000 16 NULL
8 NULL rig Belt Rig 3 0.80 4 3 1 300000 18 NULL
9 NULL rig Load Bearing Rig 3 1.00 4 4 1 350000 20 NULL
10 NULL rig High Capacity Rig 4 0.65 3 4 1 400000 24 NULL
11 NULL rigArmor Damaged Plate Carrier 2 4.50 3 3 1 250000 10 1
12 NULL rigArmor Basic Plate Carrier 2 4.20 4 3 1 270000 12 1
13 NULL rigArmor Precision Plate Carrier 3 5.90 4 3 1 300000 14 1
14 NULL rigArmor Upgraded Plate Carrier 3 6.45 3 4 1 350000 17 1
15 NULL rigArmor Multi Mission Plate Carrier 4 7.30 3 4 1 400000 18 1
16 NULL rigArmor Arma Plate Carrier 4 8.15 4 4 1 450000 19 1
17 NULL rigArmor Armored Plate Carrier 4 9.00 4 4 1 475000 20 1
18 NULL rigArmor Ranger Plate Carrier 5 9.55 4 3 1 550000 23 1
19 NULL rigArmor Assault Rig 5 12.40 3 4 1 580000 24 1
20 NULL rigArmor Armored Vest 5 14.25 4 4 1 600000 25 1
21 NULL pack Drawstring Bag 1 1.10 3 2 1 50000 6 NULL
22 NULL pack Duffle Bag 1 2.12 2 4 1 80000 8 NULL
23 NULL pack Sling Bag 1 1.85 3 3 1 100000 9 NULL
24 NULL pack Rucksack 2 2.50 4 3 1 140000 12 NULL
25 NULL pack Mini Bag 2 2.38 3 4 1 150000 12 NULL
26 NULL pack Tourist Backpack 2 2.25 5 3 1 220000 15 NULL
27 NULL pack Standard Backpack 2 1.80 4 4 1 250000 16 NULL
28 NULL pack Tactical Backpack 3 2.00 5 4 1 400000 20 NULL
29 NULL pack Takedown Backpack 3 2.50 7 3 1 500000 31 NULL
30 NULL pack Battle Backpack 3 3.00 5 5 1 600000 25 NULL
31 NULL pack Hiking Backpack 4 4.00 6 5 1 750000 30 NULL
32 NULL pack Assault Backpack 4 6.00 7 5 1 1000000 35 NULL
33 NULL pack Raid Backpack 5 8.00 8 5 1 1500000 40 NULL
34 NULL ears Peltor Comtacs 2 1.54 2 2 1 NULL NULL NULL
35 NULL ears Walker's Razor 2 0.95 2 2 1 NULL NULL NULL
36 NULL helmet Steel Helmet (2) 2 3.31 2 2 1 450000 NULL NULL
37 NULL helmet Motorcycle Helmet (1) 1 4.19 2 2 1 120000 NULL NULL
38 NULL helmet Airsoft Replica Helmet (1) 2 1.00 2 2 1 200000 NULL NULL
39 NULL helmet Military Helmet Class 4 High Cut 2 4.19 2 2 1 850000 NULL NULL
40 NULL helmet Military Helmet Class 4 Full 3 4.19 2 2 1 900000 NULL NULL
41 NULL helmet Military Helmet Class 4+ High Cut 3 4.19 2 2 1 1125000 NULL NULL
42 NULL helmet Military Helmet Class 4+ Full 4 4.19 2 2 1 1350000 NULL NULL
43 NULL armor Light Body Armor (3) 2 7.72 3 3 1 1370000 NULL NULL
44 NULL armor Bullet Proof Vest (4) 3 11.46 3 3 1 1658000 NULL NULL
45 NULL plate Class III Plate 2 5.00 3 3 1 1185000 NULL NULL
46 NULL plate Class IV Plate 3 6.00 3 3 1 1480000 NULL NULL
47 NULL plate Class IV+ Plate 4 7.00 3 3 1 1850000 NULL NULL
48 NULL pouch Pouch 1x1 1 0.15 1 1 1 25000 NULL NULL
49 NULL pouch Pouch 2x1 2 0.30 1 2 1 60000 NULL NULL
50 NULL pouch Pouch 3x1 3 0.45 1 3 1 130000 NULL NULL
51 NULL pouch Pouch 2x2 4 0.60 2 2 1 300000 NULL NULL

16
Database/data/meds.csv Normal file
View File

@ -0,0 +1,16 @@
id,type,name,rarity,weight,height,width,stack,value
NULL,meds,Bandage,1,0.1411,1,1,5,6500
NULL,meds,Small Health Kit (SHK),1,0.18,1,1,1,32000
NULL,meds,Individual First Aid Kit,2,0.22046,1,1,1,60000
NULL,meds,Dual First Aid Kit,2,0.44092,1,2,2,100000
NULL,meds,Group First Aid Kit,3,0.88184,2,2,4,120000
NULL,meds,Adaptive First Aid Kit,4,0.22046,1,1,1,90000
NULL,meds,Surgery Kit,2,0.88185,1,1,2,100000
NULL,meds,Surgery Kit (L),3,1.32278,1,2,3,150000
NULL,meds,Adrenaline,3,0.22046,1,1,1,50000
NULL,meds,Pain killer,1,0.05512,1,1,4,10000
NULL,meds,Morphine,2,0.22046,1,1,1,40000
NULL,meds,Caffeine (pill),2,0.05512,1,1,4,2500
NULL,meds,Tourniquet,1,0.37371,1,1,2,11000
NULL,meds,Muscle Stimulant,4,0,0,0,0,0
NULL,meds,Rad-x,0,0,0,0,0,0
1 id type name rarity weight height width stack value
2 NULL meds Bandage 1 0.1411 1 1 5 6500
3 NULL meds Small Health Kit (SHK) 1 0.18 1 1 1 32000
4 NULL meds Individual First Aid Kit 2 0.22046 1 1 1 60000
5 NULL meds Dual First Aid Kit 2 0.44092 1 2 2 100000
6 NULL meds Group First Aid Kit 3 0.88184 2 2 4 120000
7 NULL meds Adaptive First Aid Kit 4 0.22046 1 1 1 90000
8 NULL meds Surgery Kit 2 0.88185 1 1 2 100000
9 NULL meds Surgery Kit (L) 3 1.32278 1 2 3 150000
10 NULL meds Adrenaline 3 0.22046 1 1 1 50000
11 NULL meds Pain killer 1 0.05512 1 1 4 10000
12 NULL meds Morphine 2 0.22046 1 1 1 40000
13 NULL meds Caffeine (pill) 2 0.05512 1 1 4 2500
14 NULL meds Tourniquet 1 0.37371 1 1 2 11000
15 NULL meds Muscle Stimulant 4 0 0 0 0 0
16 NULL meds Rad-x 0 0 0 0 0 0

31
Database/data/parts.csv Normal file
View File

@ -0,0 +1,31 @@
id,type,name,rarity,weight,height,width,stack,value,vital
NULL,mag,STANAG 30-Round Magazine,1,0.375,2,1,1,100000,n
NULL,mag,Glock 22 15-Round Magazine,1,0.21164,1,1,1,70000,n
NULL,mag,Glock 33-Round Magazine,3,0.33069,2,1,1,180000,n
NULL,mag,AK47 30-Round Magazine,1,0.375,2,1,1,80000,n
NULL,muzzle,5.56 Flash Hider,1,0.33069,1,1,1,40000,n
NULL,muzzle,5.56x45 Silencer,3,0.99869,2,1,1,1000000,n
NULL,muzzle,5.56x45 Muzzle Break,2,0.33069,1,1,1,80000,n
NULL,muzzle,7.62x39 Flash Hider,1,0.33069,1,1,1,40000,n
NULL,muzzle,7.62x39 Silencer,3,0.99869,2,1,1,1000000,n
NULL,muzzle,7.62x39 Slant Break,2,0.33069,1,1,1,80000,n
NULL,rail,Laser,3,0,1,1,1,350000,n
NULL,rail,Flashlight,2,0,1,1,1,100000,n
NULL,forgrip,Vertical Foregrip,2,0,1,1,1,100000,n
NULL,forgrip,Angled Foregrip,2,0,1,1,1,0,n
NULL,optic,EOTech Holographic sight,2,0,1,1,1,700000,n
NULL,stock,Ak47 Wood Stock,1,0,2,1,1,120000,n
NULL,misc,AK47 Ribbed Dust Cover,1,0,2,1,1,130000,n
NULL,Barrels,"16"" 5.56x45 Barrel",1,0,3,1,3,750000,y
NULL,Barrels,"10"" 5.56x45 Barrel",3,0,2,1,2,1000000,y
NULL,Barrels,"20"" 5.56x45 Barrel",2,0,3,1,2,1000000,y
NULL,Handguards,"9"" Quad Rail Handguard",2,0,2,1,2,300000,y
NULL,Handguards,"15"" Quad Rail Handguard",1,0,3,1,3,500000,y
NULL,Pistol Grips,AR15 Polymer Pistol Grip,2,0,1,1,1,80000,y
NULL,Pistol Grips,A2 Pistol Grip,1,0,1,1,1,70000,y
NULL,Stocks,M16 Stock,1,0,2,1,1,200000,y
NULL,Stocks,AR15 Polymer Stock,2,0,2,1,1,250000,y
NULL,Handguards,AK47 Wood Handguard,1,0,1,1,1,120000,y
NULL,Pistol Grips,AK47 Wood Pistol Grip,1,0,1,1,1,60000,y
NULL,Pistols,"Glock 22 4.5"" Barrel",1,0,0,0,1,0,y
NULL,Pistols,Glock 22 Upper Slide,1,0,0,0,1,0,y
1 id type name rarity weight height width stack value vital
2 NULL mag STANAG 30-Round Magazine 1 0.375 2 1 1 100000 n
3 NULL mag Glock 22 15-Round Magazine 1 0.21164 1 1 1 70000 n
4 NULL mag Glock 33-Round Magazine 3 0.33069 2 1 1 180000 n
5 NULL mag AK47 30-Round Magazine 1 0.375 2 1 1 80000 n
6 NULL muzzle 5.56 Flash Hider 1 0.33069 1 1 1 40000 n
7 NULL muzzle 5.56x45 Silencer 3 0.99869 2 1 1 1000000 n
8 NULL muzzle 5.56x45 Muzzle Break 2 0.33069 1 1 1 80000 n
9 NULL muzzle 7.62x39 Flash Hider 1 0.33069 1 1 1 40000 n
10 NULL muzzle 7.62x39 Silencer 3 0.99869 2 1 1 1000000 n
11 NULL muzzle 7.62x39 Slant Break 2 0.33069 1 1 1 80000 n
12 NULL rail Laser 3 0 1 1 1 350000 n
13 NULL rail Flashlight 2 0 1 1 1 100000 n
14 NULL forgrip Vertical Foregrip 2 0 1 1 1 100000 n
15 NULL forgrip Angled Foregrip 2 0 1 1 1 0 n
16 NULL optic EOTech Holographic sight 2 0 1 1 1 700000 n
17 NULL stock Ak47 Wood Stock 1 0 2 1 1 120000 n
18 NULL misc AK47 Ribbed Dust Cover 1 0 2 1 1 130000 n
19 NULL Barrels 16" 5.56x45 Barrel 1 0 3 1 3 750000 y
20 NULL Barrels 10" 5.56x45 Barrel 3 0 2 1 2 1000000 y
21 NULL Barrels 20" 5.56x45 Barrel 2 0 3 1 2 1000000 y
22 NULL Handguards 9" Quad Rail Handguard 2 0 2 1 2 300000 y
23 NULL Handguards 15" Quad Rail Handguard 1 0 3 1 3 500000 y
24 NULL Pistol Grips AR15 Polymer Pistol Grip 2 0 1 1 1 80000 y
25 NULL Pistol Grips A2 Pistol Grip 1 0 1 1 1 70000 y
26 NULL Stocks M16 Stock 1 0 2 1 1 200000 y
27 NULL Stocks AR15 Polymer Stock 2 0 2 1 1 250000 y
28 NULL Handguards AK47 Wood Handguard 1 0 1 1 1 120000 y
29 NULL Pistol Grips AK47 Wood Pistol Grip 1 0 1 1 1 60000 y
30 NULL Pistols Glock 22 4.5" Barrel 1 0 0 0 1 0 y
31 NULL Pistols Glock 22 Upper Slide 1 0 0 0 1 0 y

View File

@ -0,0 +1,6 @@
id,type,name,rarity,weight,height,width,stack,value
NULL,m16,M16 Receiver Set,3,7.06582,2,1,1,2000000
NULL,ar15,AR15 Receiver Set,2,7.06582,2,1,1,1500000
NULL,ak47,"Stripped AK47 16"" Barrel",2,7.06582,3,1,3,1250000
NULL,glock22,Glock 22 Lower Receiver,1,0,0,0,0,0
NULL,colt1911,Colt 1911 Lower Receiver,1,0,0,0,0,0
1 id type name rarity weight height width stack value
2 NULL m16 M16 Receiver Set 3 7.06582 2 1 1 2000000
3 NULL ar15 AR15 Receiver Set 2 7.06582 2 1 1 1500000
4 NULL ak47 Stripped AK47 16" Barrel 2 7.06582 3 1 3 1250000
5 NULL glock22 Glock 22 Lower Receiver 1 0 0 0 0 0
6 NULL colt1911 Colt 1911 Lower Receiver 1 0 0 0 0 0

BIN
Database/database.db Normal file

Binary file not shown.

View File

@ -1,7 +1,9 @@
# starting_ids.py
starting_ids = {
"reloading": 20000,
"ammo": 10000,
"craft": 30000
}
"reloading": 20000,
"ammo": 10000,
"craft": 20000,
"gear": 30000,
"parts": 40000,
}

View File

@ -4,15 +4,12 @@ import sqlite3
from id import starting_ids
# Connect to the SQLite database
conn = sqlite3.connect("items.db")
conn = sqlite3.connect("database.db")
cursor = conn.cursor()
# Define the directory where the CSV files are located
csv_directory = "data" # Change this to your directory path
# Define the starting IDs for each table type
# starting_ids = {"reloading": 20000, "ammo": 10000, "craft": 30000}
# Function to load data from a CSV file into a table
def load_csv_data(csv_path, table_name, cursor, starting_id):

Binary file not shown.