projectEli/Database/ammo.py

55 lines
1.8 KiB
Python
Raw Normal View History

import sqlite3
# Connect to the SQLite database
conn = sqlite3.connect("items.db")
cursor = conn.cursor()
# Drop the existing reloading table if it exists
cursor.execute("DROP TABLE IF EXISTS ammo")
# Create the reloading table with an auto-incremented primary key
cursor.execute(
"""
CREATE TABLE ammo (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type TEXT,
name TEXT,
rarity INTEGER,
weight REAL,
width INTEGER,
height INTEGER,
stack INTEGER,
value INTEGER,
gunpowder INTEGER
)
"""
)
# id TEXT PRIMARY KEY, type TEXT, name TEXT, rarity INTEGER, weight REAL, width INTEGER, height INTEGER, value INTEGER, stack INTEGER
# Define your data to insert
data_to_insert = [
("rifle_ammo", "5.56x45 AP", 4, 0.02646, 1, 1, 7500, 30, 15),
("rifle_ammo", "5.56x45 FMJ", 1, 0.02646, 1, 1, 2500, 30, 10),
("rifle_ammo", "5.56x45 HP", 2, 0.02646, 1, 1, 5000, 30, 10),
("pistol_ammo", "9mm AP", 3, 0.01984, 1, 1, 5000, 45, 12),
("pistol_ammo", "9mm FMJ", 1, 0.01984, 1, 1, 2000, 45, 6),
("pistol_ammo", "9mm HP", 2, 0.01984, 1, 1, 4000, 45, 6),
("pistol_ammo", ".40 S&W AP", 3, 0.01984, 1, 1, 5500, 45, 13),
("pistol_ammo", ".40 S&W FMJ", 1, 0.01984, 1, 1, 3000, 45, 7),
("pistol_ammo", ".40 S&W HP", 2, 0.01984, 1, 1, 4500, 45, 7),
("rifle_ammo", "7.62x39 AP", 4, 0.02646, 1, 1, 5200, 30, 15),
("rifle_ammo", "7.62x39 FMJ", 1, 0.02646, 1, 1, 1800, 30, 10),
("rifle_ammo", "7.62x39 HP", 2, 0.02646, 1, 1, 3600, 30, 10),
]
# Insert data into the table without specifying the 'id' column
for row in data_to_insert:
cursor.execute(
"INSERT INTO ammo (type, name, rarity, weight, width, height, stack, value, gunpowder) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
row,
)
# Commit the changes and close the connection
conn.commit()
conn.close()