-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL_Vision.py
More file actions
64 lines (52 loc) · 1.86 KB
/
SQL_Vision.py
File metadata and controls
64 lines (52 loc) · 1.86 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
import os
import Color
from Extractor import Extract_Table
from Table import Display_Table
from Query import Create_Table_Query, Fill_Table_Query
print(Color.green, 'Welcome to SQL Vision', Color.reset, sep='')
path = input('Enter the Path of the Image : ')
data = Extract_Table(path)
try:
column_names = data[0]
except:
print(Color.red, 'Extraction Failed', Color.reset, sep='')
os.system('pause')
exit(0)
data_types = []
constraints = []
table_name = input('Enter the table name : ')
os.system('cls')
print('Fill in the column Data-Type and column constraints:-')
for column in column_names:
print(Color.green, f'{column}:-', Color.reset, sep='')
data_type = input('Data Type : ')
constraint = input('Constraint : ')
data_types.append(data_type)
constraints.append(constraint)
while True:
os.system('cls')
Display_Table(data)
print("If you are satisfied with the table click 'Enter'")
print('If not enter the cell coord you wish to alter')
cell = input('Coordinates (seperated by a comma) : ').replace(' ', '')
if not cell:
break
else:
try:
cell_x, cell_y = cell.split(',')
except:
print(Color.red, 'Invalid Coordinates, Press Enter', Color.reset, sep='', end=' ')
input()
continue
new_entry = input(f'Enter the Cell data for cell ({cell_x}, {cell_y}) : ')
try:
data[int(cell_x)][int(cell_y)] = new_entry
except:
print(Color.red, 'Table index out of Bounds, Press Enter', Color.reset, sep='', end=' ')
input()
os.system('cls')
print(Color.green, 'CREATE TABLE QUERY:-', Color.reset, sep='')
print(Create_Table_Query(table_name, column_names, data_types, constraints))
print(Color.green, '\nFILL TABLE QUERY:-', Color.reset, sep='')
print(Fill_Table_Query(table_name, data))
os.system('pause')