-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (41 loc) · 1.31 KB
/
main.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
from generator.join_gen import *
from generator.ddl_gen import *
from generator.data_gen import *
from config.config import *
import signal
import sys
def _signal_handler(sig, frame):
sys.exit(0)
def _interactiveMode(ddls, data):
print(ddls)
print(data)
while True:
res = input('Press x to exit or Enter to generate more')
if res.lower() == 'x':
print('Exit from query generation mode!')
sys.exit(0)
query = newQuery()
print(query)
resetConfig()
def _fileMode(ddls, data):
ddlFileName = 'out/' + getConfig().ddlOutFile
with open(ddlFileName, 'w') as ddlFile:
ddlFile.writelines([ddls, data])
queryCount = getConfig().queryCount
fileName = 'out/' + getConfig().queryOutFile
with open(fileName, 'w') as f:
queryLines = []
for _ in range(queryCount):
query = newQuery()
queryLine = query + '\n\n'
queryLines.append(queryLine)
f.writelines(queryLines)
if __name__ == '__main__':
signal.signal(signal.SIGINT, _signal_handler)
resetConfig()
ddls = getTableDDLs()
data = getTableData()
if getConfig().interactiveMode:
_interactiveMode(ddls, data)
else:
_fileMode(ddls, data)