-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsql_model.py
More file actions
193 lines (163 loc) · 9.42 KB
/
sql_model.py
File metadata and controls
193 lines (163 loc) · 9.42 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import sqlalchemy as sqla
class OmnetppTableModel:
r"""
This contains the SQLAlchemy model definitions for the tables in the OMNet++ SQLite databases.
See `here <https://docs.sqlalchemy.org/en/20/core/metadata.html>`_ for the concepts and classes used for this model.
Every table definition is preceded by the SQL statement used for creating the table.
Please note that not all relational dependencies have been implemented as the model is used for reading data, not for modifying the database.
"""
metadata = sqla.MetaData()
statistic_table = sqla.Table('statistic'
, metadata
, sqla.Column('statId', sqla.Integer, nullable=False, primary_key=True)
, sqla.Column('runId', sqla.Integer, nullable=False)
, sqla.Column('moduleName', sqla.String, nullable=False)
, sqla.Column('statName', sqla.String, nullable=False)
, sqla.Column('isHistogram', sqla.Integer, nullable=False)
, sqla.Column('isWeighted', sqla.Integer, nullable=False)
, sqla.Column('statCount', sqla.Integer, nullable=False)
, sqla.Column('statMean', sqla.Float)
, sqla.Column('statStddev', sqla.Float)
, sqla.Column('statSum', sqla.Float)
, sqla.Column('statSqrsum', sqla.Float)
, sqla.Column('statMin', sqla.Float)
, sqla.Column('statMax', sqla.Float)
, sqla.Column('statWeights', sqla.Float)
, sqla.Column('statWeightedSum', sqla.Float)
, sqla.Column('statSqrSumWeights', sqla.Float)
, sqla.Column('statWeightedSqrSum', sqla.Float)
)
r"""
Equivalent SQLite statement:
.. code-block:: sql
CREATE TABLE statistic ( statId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
, runId INTEGER NOT NULL REFERENCES run(runId) ON DELETE CASCADE
, moduleName TEXT NOT NULL, statName TEXT NOT NULL
, isHistogram INTEGER NOT NULL
, isWeighted INTEGER NOT NULL
, statCount INTEGER NOT NULL
, statMean REAL
, statStddev REAL
, statSum REAL
, statSqrsum REAL
, statMin REAL
, statMax REAL
, statWeights REAL
, statWeightedSum REAL
, statSqrSumWeights REAL
, statWeightedSqrSum REAL );
"""
scalar_table = sqla.Table('scalar'
, metadata
, sqla.Column('scalarId', sqla.Integer, nullable=False, primary_key=True)
, sqla.Column('runId', sqla.Integer, nullable=False)
, sqla.Column('moduleName', sqla.String, nullable=False)
, sqla.Column('scalarName', sqla.String, nullable=False)
, sqla.Column('scalarValue', sqla.Float)
)
r"""
Equivalent SQLite statement:
.. code-block:: sql
CREATE TABLE scalar ( scalarId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
, runId INTEGER NOT NULL REFERENCES run(runId) ON DELETE CASCADE
, moduleName TEXT NOT NULL
, scalarName TEXT NOT NULL
, scalarValue REAL );
"""
vector_table = sqla.Table('vector'
, metadata
, sqla.Column('vectorId', sqla.Integer, nullable=False, primary_key=True)
, sqla.Column('moduleName', sqla.String, nullable=False)
, sqla.Column('vectorName', sqla.String, nullable=False)
)
r"""
Equivalent SQLite statement:
.. code-block:: sql
CREATE TABLE vector ( vectorId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
, runId INTEGER NOT NULL REFERENCES run(runId) ON DELETE CASCADE
, moduleName TEXT NOT NULL, vectorName TEXT NOT NULL
, vectorCount INTEGER
, vectorMin REAL
, vectorMax REAL
, vectorSum REAL
, vectorSumSqr REAL
, startEventNum INTEGER
, endEventNum INTEGER
, startSimtimeRaw INTEGER
, endSimtimeRaw INTEGER );
"""
vectorData_table = sqla.Table('vectorData'
, metadata
, sqla.Column('rowId', sqla.Integer, nullable=False, primary_key=True)
, sqla.Column('vectorId', None, sqla.ForeignKey('vector.vectorId'), nullable=False)
, sqla.Column('eventNumber', sqla.Integer, nullable=False)
, sqla.Column('simtimeRaw', sqla.Integer, nullable=False)
, sqla.Column('value', sqla.Float)
)
r"""
Equivalent SQLite statement:
.. code-block:: sql
CREATE TABLE vectorData ( vectorId INTEGER NOT NULL REFERENCES vector(vectorId) ON DELETE CASCADE
, eventNumber INTEGER NOT NULL
, simtimeRaw INTEGER NOT NULL
, value REAL );
"""
run_table = sqla.Table('run'
, metadata
, sqla.Column('runId', sqla.Integer, nullable=False, primary_key=True)
, sqla.Column('runName', sqla.String, nullable=False)
, sqla.Column('simtimeExp', sqla.Integer, nullable=False)
)
r"""
Equivalent SQLite statement:
.. code-block:: sql
CREATE TABLE run ( runId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
, runName TEXT NOT NULL
, simtimeExp INTEGER NOT NULL );
"""
runAttr_table = sqla.Table('runAttr'
, metadata
, sqla.Column('rowId', sqla.Integer, nullable=False, primary_key=True)
, sqla.Column('runId', None, sqla.ForeignKey('run.runId'), nullable=False)
, sqla.Column('attrName', sqla.String, nullable=False)
, sqla.Column('attrValue', sqla.String, nullable=False)
)
r"""
Equivalent SQLite statement:
.. code-block:: sql
CREATE TABLE runAttr ( runId INTEGER NOT NULL REFERENCES run(runId) ON DELETE CASCADE
, attrName TEXT NOT NULL
, attrValue TEXT NOT NULL );
"""
runParam_table = sqla.Table('runParam'
, metadata
, sqla.Column('rowId', sqla.Integer, nullable=False, primary_key=True)
, sqla.Column('runId', None, sqla.ForeignKey('run.runId'), nullable=False)
, sqla.Column('paramKey', sqla.String, nullable=False)
, sqla.Column('paramValue', sqla.String, nullable=False)
, sqla.Column('paramOrder', sqla.Integer, nullable=False)
)
r"""
Equivalent SQLite statement:
.. code-block:: sql
CREATE TABLE runParam ( runId INTEGER NOT NULL REFERENCES run(runId) ON DELETE CASCADE
, paramKey TEXT NOT NULL
, paramValue TEXT NOT NULL
, paramOrder INTEGER NOT NULL );
"""
runConfig_table = sqla.Table('runConfig'
, metadata
, sqla.Column('rowId', sqla.Integer, nullable=False, primary_key=True)
, sqla.Column('runId', None, sqla.ForeignKey('run.runId'), nullable=False)
, sqla.Column('configKey', sqla.String, nullable=False)
, sqla.Column('configValue', sqla.String, nullable=False)
, sqla.Column('configOrder', sqla.Integer, nullable=False)
)
r"""
Equivalent SQLite statement:
.. code-block:: sql
CREATE TABLE runConfig ( runId INTEGER NOT NULL REFERENCES run(runId) ON DELETE CASCADE
, configKey TEXT NOT NULL
, configValue TEXT NOT NULL
, configOrder INTEGER NOT NULL );
"""