import sqlite3 import random from datetime import datetime, timedelta # Connect to the database conn = sqlite3.connect('business_data.db') c = conn.cursor() # --- Product Table --- product_names = [f"Product {i:03d}" for i in range(1, 101)] categories = ["Electronics", "Clothing", "Home", "Toys", "Books", "Sports"] brands = ["BrandA", "BrandB", "BrandC", "BrandD"] products = [] for i, name in enumerate(product_names, 1): products.append((f"P{i:03d}", name, random.choice(categories), random.choice(brands), random.randint(10, 500), round(random.uniform(100, 2000), 2))) c.executemany('INSERT OR IGNORE INTO Product ("Product ID", "Product Name", "Category", "Brand", "Stock Quantity", "Price (USD)") VALUES (?, ?, ?, ?, ?, ?)', products) # --- Location Table --- places = [f"Store {i:02d}" for i in range(1, 21)] countries = ["USA", "UK", "Germany", "France", "India", "Japan", "Brazil", "Canada"] store_types = ["Mall", "Online", "Outlet", "Supermarket"] locations = [] for i in range(1, 201): locations.append((i, random.choice(places), random.choice(countries), random.choice(store_types))) c.executemany('INSERT OR IGNORE INTO Location ("Sale ID", "Place", "Country", "Store Type") VALUES (?, ?, ?, ?)', locations) # --- Sales Table --- sale_rows = [] payment_methods = ["Credit Card", "Cash", "PayPal", "UPI"] start_date = datetime(2023, 1, 1) for i in range(1, 2001): sale_id = i product_id = random.choice(products)[0] date = (start_date + timedelta(days=random.randint(0, 540))).strftime('%Y-%m-%d') revenue = round(random.uniform(100, 5000), 2) discount = random.choice([0, 5, 10, 15, 20, 25]) payment = random.choice(payment_methods) volume = random.randint(1, 20) sale = (sale_id, product_id, date, revenue, discount, payment, volume) sale_rows.append(sale) c.executemany('INSERT OR IGNORE INTO Sales ("Sale ID", "Product ID", "Date", "Revenue (USD)", "Discount (%)", "Payment Method", "Volume Sold") VALUES (?, ?, ?, ?, ?, ?, ?)', sale_rows) conn.commit() conn.close() print("Sample data inserted: 100 products, 200 locations, 2000 sales.")