forked from ombegov/dcoi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateDatabase.py
74 lines (64 loc) · 1.48 KB
/
createDatabase.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
###
# This script creates a local sqlite database for procecssing DCOI data.
###
import argparse
import sqlite3
import config
conn = sqlite3.connect(config.DB_CONFIG['file'])
c = conn.cursor()
c.execute('''
CREATE TABLE IF NOT EXISTS datacenters (
id TEXT,
year INT,
quarter INT,
agency TEXT,
component TEXT,
ownershipType TEXT,
sharedServicesPosition TEXT,
tier TEXT,
country TEXT,
grossFloorArea INTEGER,
keyMissionFacility INTEGER,
keyMissionFacilityType TEXT,
optimizationExempt INTEGER,
electricityMetered INTEGER,
avgElectricityUsage REAL,
avgITElectricityUsage REAL,
underutilizedServers INTEGER,
downtimeHours REAL,
plannedAvailabilityHours REAL,
mainframesCount INTEGER,
HPCCount INTEGER,
serverCount INTEGER,
virtualHostCount INTEGER,
closingStage TEXT,
closingTargetDate TEXT,
comments TEXT
)
''')
# We store our floats as TEXT. See https://github.com/ombegov/dcoi/issues/6
c.execute('''
CREATE TABLE IF NOT EXISTS stratplans (
agency TEXT,
importDate INTEGER,
type TEXT,
fy16Planned TEXT,
fy16Achieved TEXT,
fy17Planned TEXT,
fy17Achieved TEXT,
fy18Planned TEXT,
fy18Achieved TEXT,
fy19Planned TEXT,
fy19Achieved TEXT,
fy20Planned TEXT,
fy20Achieved TEXT,
explanation TEXT,
methodology TEXT,
costsOfClosures TEXT,
costsOfOptimization TEXT,
historicalCostSavings TEXT
)
''')
conn.commit()
conn.close()
exit()