-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_db.py
More file actions
50 lines (41 loc) · 1.07 KB
/
Copy pathcreate_db.py
File metadata and controls
50 lines (41 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sqlite3
conn = sqlite3.connect("operations.db")
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS orders (
order_id TEXT PRIMARY KEY,
customer_name TEXT,
status TEXT,
amount REAL,
issue TEXT
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS customers (
customer_id TEXT PRIMARY KEY,
customer_name TEXT,
industry TEXT,
region TEXT
)
""")
orders_data = [
("1001", "ABC Textile", "Delayed", 12000.0, "Raw material shortage"),
("1002", "Blue Yarn Co", "Shipped", 8500.0, "None"),
("1003", "Ever Wool Ltd", "Processing", 15000.0, "Machine maintenance")
]
customers_data = [
("C001", "ABC Textile", "Textile", "Canada"),
("C002", "Blue Yarn Co", "Manufacturing", "USA"),
("C003", "Ever Wool Ltd", "Fashion", "UK")
]
cursor.executemany(
"INSERT OR REPLACE INTO orders VALUES (?, ?, ?, ?, ?)",
orders_data
)
cursor.executemany(
"INSERT OR REPLACE INTO customers VALUES (?, ?, ?, ?)",
customers_data
)
conn.commit()
conn.close()
print("Database created and data inserted successfully.")