-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
29 lines (25 loc) · 823 Bytes
/
database.py
File metadata and controls
29 lines (25 loc) · 823 Bytes
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
import sqlite3
class DatabaseManager:
def __init__(self, db_name):
self.conn = sqlite3.connect(db_name)
self.cursor = self.conn.cursor()
self.initialize_database()
def initialize_database(self):
self.cursor.execute("""
CREATE TABLE IF NOT EXISTS cost_data (
Material TEXT,
BaseRate REAL,
MaintenanceRate REAL,
RepairRate REAL,
DemolitionRate REAL,
EnvironmentalFactor REAL,
SocialFactor REAL,
DelayFactor REAL
)
""")
self.conn.commit()
def fetch_all_cost_data(self):
self.cursor.execute("SELECT * FROM cost_data")
return self.cursor.fetchall()
def close(self):
self.conn.close()