sql-testing-tools 0.1.8__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/PKG-INFO +35 -29
- sql_testing_tools-0.2.0/README.md +25 -0
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/setup.cfg +4 -4
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/setup.py +16 -16
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools/BaseAccess.py +170 -170
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools/Helper.py +214 -210
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools/TokenProcessing.py +369 -359
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools/__init__.py +3 -3
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools.egg-info/PKG-INFO +35 -29
- sql_testing_tools-0.1.8/README.md +0 -3
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools.egg-info/SOURCES.txt +0 -0
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools.egg-info/dependency_links.txt +0 -0
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools.egg-info/requires.txt +0 -0
- {sql_testing_tools-0.1.8 → sql_testing_tools-0.2.0}/sql_testing_tools.egg-info/top_level.txt +0 -0
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: sql_testing_tools
|
|
3
|
-
Version: 0.
|
|
4
|
-
Description-Content-Type: text/markdown
|
|
5
|
-
Requires-Dist: sqlparse>=0.5.1
|
|
6
|
-
Requires-Dist: requests>=2.32.3
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### V 0.1.
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
### V 0.1.
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: sql_testing_tools
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Description-Content-Type: text/markdown
|
|
5
|
+
Requires-Dist: sqlparse>=0.5.1
|
|
6
|
+
Requires-Dist: requests>=2.32.3
|
|
7
|
+
Dynamic: description
|
|
8
|
+
Dynamic: description-content-type
|
|
9
|
+
Dynamic: requires-dist
|
|
10
|
+
|
|
11
|
+
A library that normalizes simple SQL queries and compares them first by equality of the normalized string and then using the cosette API.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### [Beta in Development!]
|
|
15
|
+
[](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-build.yml)
|
|
16
|
+
[](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-unittests.yml)
|
|
17
|
+
|
|
18
|
+
### V 0.1.9 + 0.2.0
|
|
19
|
+
- Support ORDER BY
|
|
20
|
+
|
|
21
|
+
### V 0.1.8
|
|
22
|
+
- Fixed linebreak problems: Linebreaks are now converted into whitespaces before parsing where tokens
|
|
23
|
+
|
|
24
|
+
### V 0.1.6 + V 0.1.7
|
|
25
|
+
- Fixed import error to ensure imports working in different environemnts
|
|
26
|
+
|
|
27
|
+
### V 0.1.4 + V 0.1.5
|
|
28
|
+
- V0.1.5 is just a reupload of V 0.1.4
|
|
29
|
+
- Chained conditions (with AND,OR and Paranthesises) in WHERE statement
|
|
30
|
+
|
|
31
|
+
### V 0.1.3
|
|
32
|
+
- SELECT: columns with our without table prefix
|
|
33
|
+
- FROM: one or more table from DB; no queries as tables!
|
|
34
|
+
- WHERE: single conditions; no Paranthesises!
|
|
35
|
+
- GROUP BY one or more columns
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
A library that normalizes simple SQL queries and compares them first by equality of the normalized string and then using the cosette API.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### [Beta in Development!]
|
|
5
|
+
[](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-build.yml)
|
|
6
|
+
[](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-unittests.yml)
|
|
7
|
+
|
|
8
|
+
### V 0.1.9 + 0.2.0
|
|
9
|
+
- Support ORDER BY
|
|
10
|
+
|
|
11
|
+
### V 0.1.8
|
|
12
|
+
- Fixed linebreak problems: Linebreaks are now converted into whitespaces before parsing where tokens
|
|
13
|
+
|
|
14
|
+
### V 0.1.6 + V 0.1.7
|
|
15
|
+
- Fixed import error to ensure imports working in different environemnts
|
|
16
|
+
|
|
17
|
+
### V 0.1.4 + V 0.1.5
|
|
18
|
+
- V0.1.5 is just a reupload of V 0.1.4
|
|
19
|
+
- Chained conditions (with AND,OR and Paranthesises) in WHERE statement
|
|
20
|
+
|
|
21
|
+
### V 0.1.3
|
|
22
|
+
- SELECT: columns with our without table prefix
|
|
23
|
+
- FROM: one or more table from DB; no queries as tables!
|
|
24
|
+
- WHERE: single conditions; no Paranthesises!
|
|
25
|
+
- GROUP BY one or more columns
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
from setuptools import setup, find_packages
|
|
2
|
-
|
|
3
|
-
with open("
|
|
4
|
-
description = fh.read()
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
setup(
|
|
8
|
-
name='sql_testing_tools',
|
|
9
|
-
version='0.
|
|
10
|
-
packages=find_packages(),
|
|
11
|
-
install_requires=[
|
|
12
|
-
'sqlparse>=0.5.1',
|
|
13
|
-
'requests>=2.32.3'
|
|
14
|
-
],
|
|
15
|
-
long_description=description,
|
|
16
|
-
long_description_content_type="text/markdown"
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r") as fh:
|
|
4
|
+
description = fh.read()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name='sql_testing_tools',
|
|
9
|
+
version='0.2.0',
|
|
10
|
+
packages=find_packages(),
|
|
11
|
+
install_requires=[
|
|
12
|
+
'sqlparse>=0.5.1',
|
|
13
|
+
'requests>=2.32.3'
|
|
14
|
+
],
|
|
15
|
+
long_description=description,
|
|
16
|
+
long_description_content_type="text/markdown"
|
|
17
17
|
)
|
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import sqlite3
|
|
2
|
-
import os
|
|
3
|
-
#from importlib import resources
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
__db=""
|
|
7
|
-
|
|
8
|
-
def setDBName(
|
|
9
|
-
global __db
|
|
10
|
-
print("Setting DB to: " +
|
|
11
|
-
__db =
|
|
12
|
-
#with resources.path('sql_testing_tools',
|
|
13
|
-
# __db = str(db_path)
|
|
14
|
-
# print(__db)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
setDBName("bayern.db")
|
|
18
|
-
|
|
19
|
-
def run(sql: str):
|
|
20
|
-
con = sqlite3.connect(__db)
|
|
21
|
-
cur = con.cursor()
|
|
22
|
-
cur.execute(sql)
|
|
23
|
-
con.commit()
|
|
24
|
-
return cur
|
|
25
|
-
|
|
26
|
-
def runFromFile(path: str):
|
|
27
|
-
sql = getSQLFromFile(path)
|
|
28
|
-
if not sql:
|
|
29
|
-
raise Exception("\nSQL-Datei ist leer. Aufgabe wurde noch nicht bearbeitet.")
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if sql.lower().find("drop") != -1:
|
|
33
|
-
raise Exception("Guter Versuch, aber die Datenbank wird bei jedem Upload zurückgesetzt ;)")
|
|
34
|
-
|
|
35
|
-
try:
|
|
36
|
-
res = run(sql)
|
|
37
|
-
except Exception as e:
|
|
38
|
-
raise Exception(f"\n\nSyntax-Fehler in der SQL-Abfrage:\n{str(e)}")
|
|
39
|
-
|
|
40
|
-
headers = [h[0] for h in res.description] if res.description else []
|
|
41
|
-
rows = res.fetchall() if res else []
|
|
42
|
-
|
|
43
|
-
return headers, rows
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def runAndGetStringTable_fromFile(path: str, count: int = 5, maxLineLength: int = 85):
|
|
47
|
-
try:
|
|
48
|
-
headers, rows = runFromFile(path)
|
|
49
|
-
resultCount = len(rows)
|
|
50
|
-
rows = rows[:count]
|
|
51
|
-
s = ""
|
|
52
|
-
|
|
53
|
-
matrix = [] #[[]*(len(rows)+1)]*len(headers)
|
|
54
|
-
|
|
55
|
-
for col in range(len(headers)):
|
|
56
|
-
matrix.append([])
|
|
57
|
-
matrix[-1].append(headers[col])
|
|
58
|
-
|
|
59
|
-
if rows is not None:
|
|
60
|
-
for col in range(len(matrix)):
|
|
61
|
-
for row in range(0, len(rows)):
|
|
62
|
-
if len(rows[row]) > col:
|
|
63
|
-
matrix[col].append(rows[row][col])
|
|
64
|
-
|
|
65
|
-
for col in range(len(matrix)):
|
|
66
|
-
maxLength = max([len(str(x)) for x in matrix[col]])
|
|
67
|
-
|
|
68
|
-
for row in range(0, len(matrix[col])):
|
|
69
|
-
matrix[col][row] = str(matrix[col][row]).ljust(maxLength)
|
|
70
|
-
|
|
71
|
-
normalizedRows = []
|
|
72
|
-
spacing = " "
|
|
73
|
-
spacingLength = len(spacing) * (len(matrix[0]) - 1)
|
|
74
|
-
|
|
75
|
-
lineLength = sum([len(x[0]) for x in matrix]) + spacingLength
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if lineLength > maxLineLength:
|
|
80
|
-
valLength = lineLength - spacingLength
|
|
81
|
-
maxColLength = int(maxLineLength/len(matrix))
|
|
82
|
-
|
|
83
|
-
for col in range(len(matrix)):
|
|
84
|
-
for row in range(0, len(matrix[col])):
|
|
85
|
-
cutContent = len(matrix[col][row].strip()) > maxColLength
|
|
86
|
-
if cutContent:
|
|
87
|
-
matrix[col][row] = matrix[col][row][:maxColLength-2] + ".."
|
|
88
|
-
else:
|
|
89
|
-
matrix[col][row] = matrix[col][row][:maxColLength]
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
for row in range(min(count+1, len(matrix[0]))):
|
|
93
|
-
normalizedRows.append(spacing.join([str(matrix[col][row]) for col in range(len(matrix))]))
|
|
94
|
-
normalizedRows.insert(1, len(normalizedRows[0])*"-")
|
|
95
|
-
|
|
96
|
-
s = "\n".join(normalizedRows[:count+2])
|
|
97
|
-
s += "\n" + normalizedRows[1]
|
|
98
|
-
|
|
99
|
-
if (resultCount > count):
|
|
100
|
-
s += "\n... " + str(resultCount - count) + " weitere Zeilen"
|
|
101
|
-
else:
|
|
102
|
-
s += "\n... keine weiteren Zeilen"
|
|
103
|
-
|
|
104
|
-
#longestLineInS = 85 # max([len(x.replace("\t", " ")) for x in s.split("\n")])
|
|
105
|
-
|
|
106
|
-
#s = "-" * longestLineInS + "\n" + s + "\n" + "-" * longestLineInS
|
|
107
|
-
s = "\n\nDiese Meldung sagt nichts über die Korrektheit der Abgabe aus!\nDie ersten " + str(
|
|
108
|
-
count) + " Zeilen des Ergebnisses der SQL-Abfrage:\n\n" + s
|
|
109
|
-
|
|
110
|
-
return s.replace("None", "NULL")
|
|
111
|
-
except Exception as ex:
|
|
112
|
-
raise ex
|
|
113
|
-
|
|
114
|
-
def getSQLFromFile(path: str):
|
|
115
|
-
try:
|
|
116
|
-
with open(path, "r") as f:
|
|
117
|
-
s = f.read()
|
|
118
|
-
if not s:
|
|
119
|
-
raise Exception("\nSQL-Datei ist leer. Aufgabe wurde noch nicht bearbeitet.")
|
|
120
|
-
return s
|
|
121
|
-
except FileNotFoundError:
|
|
122
|
-
raise Exception(f"\nSQL-Datei nicht gefunden! Überprüfe, dass der Name korrekt ist ({path.split('/')[-1]}) und die Datei nicht gelöscht oder in einen Unterordner verschoben wurde.")
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def getWorkingDir():
|
|
127
|
-
return os.getcwd()
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def getWorkingDirFiles():
|
|
131
|
-
return os.listdir()
|
|
132
|
-
|
|
133
|
-
def mapDatabaseTypes(t):
|
|
134
|
-
# Map SQLite types to Python types
|
|
135
|
-
type_mapping = {
|
|
136
|
-
"INTEGER": "int",
|
|
137
|
-
"TEXT": "str",
|
|
138
|
-
"VARCHAR": "str",
|
|
139
|
-
"REAL": "float",
|
|
140
|
-
"BLOB": "bytes",
|
|
141
|
-
"NUMERIC": "float",
|
|
142
|
-
"DOUBLE": "float"
|
|
143
|
-
}
|
|
144
|
-
t = t.upper()
|
|
145
|
-
t = type_mapping.get(t, t)
|
|
146
|
-
|
|
147
|
-
if "INT" in t:
|
|
148
|
-
t = "int"
|
|
149
|
-
elif "VARCHAR" in t:
|
|
150
|
-
t = "str"
|
|
151
|
-
elif "CHAR" in t:
|
|
152
|
-
t = "str"
|
|
153
|
-
|
|
154
|
-
return t
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def getTableDict():
|
|
160
|
-
res = run("SELECT name FROM sqlite_master WHERE type='table';")
|
|
161
|
-
tables = res.fetchall()
|
|
162
|
-
|
|
163
|
-
table_dict = {}
|
|
164
|
-
for table in tables:
|
|
165
|
-
res = run(f"PRAGMA table_info({table[0]})")
|
|
166
|
-
r = res.fetchall()
|
|
167
|
-
if table[0] == "sqlite_sequence":
|
|
168
|
-
continue
|
|
169
|
-
table_dict[table[0]] = [[c[1], mapDatabaseTypes(c[2])] for c in r]
|
|
170
|
-
|
|
1
|
+
import sqlite3
|
|
2
|
+
import os
|
|
3
|
+
#from importlib import resources
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
__db=""
|
|
7
|
+
|
|
8
|
+
def setDBName(path: str):
|
|
9
|
+
global __db
|
|
10
|
+
print("Setting DB to: " + path)
|
|
11
|
+
__db = path
|
|
12
|
+
#with resources.path('sql_testing_tools', path) as db_path:
|
|
13
|
+
# __db = str(db_path)
|
|
14
|
+
# print(__db)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#setDBName("databases/bayern.db")
|
|
18
|
+
|
|
19
|
+
def run(sql: str):
|
|
20
|
+
con = sqlite3.connect(__db)
|
|
21
|
+
cur = con.cursor()
|
|
22
|
+
cur.execute(sql)
|
|
23
|
+
con.commit()
|
|
24
|
+
return cur
|
|
25
|
+
|
|
26
|
+
def runFromFile(path: str):
|
|
27
|
+
sql = getSQLFromFile(path)
|
|
28
|
+
if not sql:
|
|
29
|
+
raise Exception("\nSQL-Datei ist leer. Aufgabe wurde noch nicht bearbeitet.")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if sql.lower().find("drop") != -1:
|
|
33
|
+
raise Exception("Guter Versuch, aber die Datenbank wird bei jedem Upload zurückgesetzt ;)")
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
res = run(sql)
|
|
37
|
+
except Exception as e:
|
|
38
|
+
raise Exception(f"\n\nSyntax-Fehler in der SQL-Abfrage:\n{str(e)}")
|
|
39
|
+
|
|
40
|
+
headers = [h[0] for h in res.description] if res.description else []
|
|
41
|
+
rows = res.fetchall() if res else []
|
|
42
|
+
|
|
43
|
+
return headers, rows
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def runAndGetStringTable_fromFile(path: str, count: int = 5, maxLineLength: int = 85):
|
|
47
|
+
try:
|
|
48
|
+
headers, rows = runFromFile(path)
|
|
49
|
+
resultCount = len(rows)
|
|
50
|
+
rows = rows[:count]
|
|
51
|
+
s = ""
|
|
52
|
+
|
|
53
|
+
matrix = [] #[[]*(len(rows)+1)]*len(headers)
|
|
54
|
+
|
|
55
|
+
for col in range(len(headers)):
|
|
56
|
+
matrix.append([])
|
|
57
|
+
matrix[-1].append(headers[col])
|
|
58
|
+
|
|
59
|
+
if rows is not None:
|
|
60
|
+
for col in range(len(matrix)):
|
|
61
|
+
for row in range(0, len(rows)):
|
|
62
|
+
if len(rows[row]) > col:
|
|
63
|
+
matrix[col].append(rows[row][col])
|
|
64
|
+
|
|
65
|
+
for col in range(len(matrix)):
|
|
66
|
+
maxLength = max([len(str(x)) for x in matrix[col]])
|
|
67
|
+
|
|
68
|
+
for row in range(0, len(matrix[col])):
|
|
69
|
+
matrix[col][row] = str(matrix[col][row]).ljust(maxLength)
|
|
70
|
+
|
|
71
|
+
normalizedRows = []
|
|
72
|
+
spacing = " "
|
|
73
|
+
spacingLength = len(spacing) * (len(matrix[0]) - 1)
|
|
74
|
+
|
|
75
|
+
lineLength = sum([len(x[0]) for x in matrix]) + spacingLength
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if lineLength > maxLineLength:
|
|
80
|
+
valLength = lineLength - spacingLength
|
|
81
|
+
maxColLength = int(maxLineLength/len(matrix))
|
|
82
|
+
|
|
83
|
+
for col in range(len(matrix)):
|
|
84
|
+
for row in range(0, len(matrix[col])):
|
|
85
|
+
cutContent = len(matrix[col][row].strip()) > maxColLength
|
|
86
|
+
if cutContent:
|
|
87
|
+
matrix[col][row] = matrix[col][row][:maxColLength-2] + ".."
|
|
88
|
+
else:
|
|
89
|
+
matrix[col][row] = matrix[col][row][:maxColLength]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
for row in range(min(count+1, len(matrix[0]))):
|
|
93
|
+
normalizedRows.append(spacing.join([str(matrix[col][row]) for col in range(len(matrix))]))
|
|
94
|
+
normalizedRows.insert(1, len(normalizedRows[0])*"-")
|
|
95
|
+
|
|
96
|
+
s = "\n".join(normalizedRows[:count+2])
|
|
97
|
+
s += "\n" + normalizedRows[1]
|
|
98
|
+
|
|
99
|
+
if (resultCount > count):
|
|
100
|
+
s += "\n... " + str(resultCount - count) + " weitere Zeilen"
|
|
101
|
+
else:
|
|
102
|
+
s += "\n... keine weiteren Zeilen"
|
|
103
|
+
|
|
104
|
+
#longestLineInS = 85 # max([len(x.replace("\t", " ")) for x in s.split("\n")])
|
|
105
|
+
|
|
106
|
+
#s = "-" * longestLineInS + "\n" + s + "\n" + "-" * longestLineInS
|
|
107
|
+
s = "\n\nDiese Meldung sagt nichts über die Korrektheit der Abgabe aus!\nDie ersten " + str(
|
|
108
|
+
count) + " Zeilen des Ergebnisses der SQL-Abfrage:\n\n" + s
|
|
109
|
+
|
|
110
|
+
return s.replace("None", "NULL")
|
|
111
|
+
except Exception as ex:
|
|
112
|
+
raise ex
|
|
113
|
+
|
|
114
|
+
def getSQLFromFile(path: str):
|
|
115
|
+
try:
|
|
116
|
+
with open(path, "r") as f:
|
|
117
|
+
s = f.read()
|
|
118
|
+
if not s:
|
|
119
|
+
raise Exception("\nSQL-Datei ist leer. Aufgabe wurde noch nicht bearbeitet.")
|
|
120
|
+
return s
|
|
121
|
+
except FileNotFoundError:
|
|
122
|
+
raise Exception(f"\nSQL-Datei nicht gefunden! Überprüfe, dass der Name korrekt ist ({path.split('/')[-1]}) und die Datei nicht gelöscht oder in einen Unterordner verschoben wurde.")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def getWorkingDir():
|
|
127
|
+
return os.getcwd()
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def getWorkingDirFiles():
|
|
131
|
+
return os.listdir()
|
|
132
|
+
|
|
133
|
+
def mapDatabaseTypes(t):
|
|
134
|
+
# Map SQLite types to Python types
|
|
135
|
+
type_mapping = {
|
|
136
|
+
"INTEGER": "int",
|
|
137
|
+
"TEXT": "str",
|
|
138
|
+
"VARCHAR": "str",
|
|
139
|
+
"REAL": "float",
|
|
140
|
+
"BLOB": "bytes",
|
|
141
|
+
"NUMERIC": "float",
|
|
142
|
+
"DOUBLE": "float"
|
|
143
|
+
}
|
|
144
|
+
t = t.upper()
|
|
145
|
+
t = type_mapping.get(t, t)
|
|
146
|
+
|
|
147
|
+
if "INT" in t:
|
|
148
|
+
t = "int"
|
|
149
|
+
elif "VARCHAR" in t:
|
|
150
|
+
t = "str"
|
|
151
|
+
elif "CHAR" in t:
|
|
152
|
+
t = "str"
|
|
153
|
+
|
|
154
|
+
return t
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def getTableDict():
|
|
160
|
+
res = run("SELECT name FROM sqlite_master WHERE type='table';")
|
|
161
|
+
tables = res.fetchall()
|
|
162
|
+
|
|
163
|
+
table_dict = {}
|
|
164
|
+
for table in tables:
|
|
165
|
+
res = run(f"PRAGMA table_info({table[0]})")
|
|
166
|
+
r = res.fetchall()
|
|
167
|
+
if table[0] == "sqlite_sequence":
|
|
168
|
+
continue
|
|
169
|
+
table_dict[table[0]] = [[c[1], mapDatabaseTypes(c[2])] for c in r]
|
|
170
|
+
|
|
171
171
|
return table_dict
|