31 lines
962 B
Python
31 lines
962 B
Python
import sqlite3
|
|
|
|
def add_test_data():
|
|
conn = sqlite3.connect('shop.db')
|
|
cursor = conn.cursor()
|
|
|
|
# Lösche vorhandene Daten
|
|
cursor.execute("DELETE FROM products")
|
|
|
|
# Testprodukte
|
|
products = [
|
|
("Gaming Maus", "Hochwertige Gaming-Maus mit RGB-Beleuchtung", 49.99, 10),
|
|
("Mechanische Tastatur", "Mechanische Gaming-Tastatur mit blauen Switches", 89.99, 5),
|
|
("Gaming Headset", "7.1 Surround Sound Gaming Headset", 79.99, 8),
|
|
("Mousepad XL", "Extra großes Gaming-Mousepad", 19.99, 15),
|
|
("Webcam HD", "1080p Webcam für Streaming", 59.99, 3)
|
|
]
|
|
|
|
# Füge Produkte ein
|
|
cursor.executemany(
|
|
"INSERT INTO products (name, description, price, stock) VALUES (?, ?, ?, ?)",
|
|
products
|
|
)
|
|
|
|
# Speichere Änderungen
|
|
conn.commit()
|
|
conn.close()
|
|
print("Testdaten wurden erfolgreich hinzugefügt!")
|
|
|
|
if __name__ == "__main__":
|
|
add_test_data() |