58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
import sqlite3
|
|
|
|
# Verbindung zur Datenbank herstellen (eine neue Datenbank wird erstellt, wenn sie nicht vorhanden ist)
|
|
connection = sqlite3.connect('webseiten.db')
|
|
cursor = connection.cursor()
|
|
|
|
# Tabelle für Kategorien erstellen
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS categories (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL
|
|
)
|
|
''')
|
|
|
|
# Tabelle für Webseiten erstellen
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS webpages (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
category_id INTEGER,
|
|
FOREIGN KEY (category_id) REFERENCES categories (id)
|
|
)
|
|
''')
|
|
|
|
# Kategorien hinzufügen
|
|
categories = ["IT/Elektronik", "Baumarkt", "Schilder", "Verpackungen",
|
|
"Küchenbedarf", "Reinigungs Artikel", "Büro Artikel",
|
|
"Deko", "Landwirtschaft/Garten", "Arbeitsschutz", "Hygiene",
|
|
"Etiketten/Papier", "Drogentest"]
|
|
|
|
for category in categories:
|
|
cursor.execute("INSERT INTO categories (name) VALUES (?)", (category,))
|
|
|
|
# Webseiten hinzufügen
|
|
webpages = [
|
|
["Reichelt", "Kosatec", "Conrad"],
|
|
["Hornbach", "Esska","Contorion","Gastroteile Shop", "TiroLED", "Megabad", "Baubeschlagshop", "IPS", "Häfele", "Delker", "Knauss"],
|
|
["Brewes", "Schildershop24", "Skiltex", "VKF-Renzel"],
|
|
["Papstar", "Pacovis", "Transpak", "TVV-Verpackungen", "Eierschachteln.de", "DM-Folien"],
|
|
["Esmeyer", "Lusini", "Tischwelt", "Schafferer", "Gastronomie Kaufhaus", "Börner", "GGM-Gastro"],
|
|
["Hygi", "Proficlean Shop", "Reinigungsberater", "Franz-Mensch"],
|
|
["Böttcher", "Buchhandlung am Markt", "Büroshop24.de"],
|
|
["Frank-Flechtwaren", "Betzold", "VBS-Hobby"],
|
|
["Siepmann", "FK-Söhnchen", "Wahl-Agar", "KOX"],
|
|
["Arbeitsplatzmatten Profi", "ARA"],
|
|
["Rossmann"],
|
|
["PML", "Label-Ident"],
|
|
["Ökonomed"]
|
|
]
|
|
|
|
for category_id, webpage_list in enumerate(webpages, start=1):
|
|
for webpage in webpage_list:
|
|
cursor.execute("INSERT INTO webpages (name, category_id) VALUES (?, ?)", (webpage, category_id))
|
|
|
|
# Änderungen speichern und Verbindung schließen
|
|
connection.commit()
|
|
connection.close()
|