quillsql 0.6__tar.gz → 0.8__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.
- {quillsql-0.6 → quillsql-0.8}/PKG-INFO +1 -1
- {quillsql-0.6 → quillsql-0.8}/quillsql/core.py +76 -9
- {quillsql-0.6 → quillsql-0.8}/quillsql.egg-info/PKG-INFO +1 -1
- {quillsql-0.6 → quillsql-0.8}/setup.py +1 -1
- {quillsql-0.6 → quillsql-0.8}/LICENSE +0 -0
- {quillsql-0.6 → quillsql-0.8}/README.md +0 -0
- {quillsql-0.6 → quillsql-0.8}/quillsql/__init__.py +0 -0
- {quillsql-0.6 → quillsql-0.8}/quillsql.egg-info/SOURCES.txt +0 -0
- {quillsql-0.6 → quillsql-0.8}/quillsql.egg-info/dependency_links.txt +0 -0
- {quillsql-0.6 → quillsql-0.8}/quillsql.egg-info/requires.txt +0 -0
- {quillsql-0.6 → quillsql-0.8}/quillsql.egg-info/top_level.txt +0 -0
- {quillsql-0.6 → quillsql-0.8}/setup.cfg +0 -0
|
@@ -42,18 +42,16 @@ class Quill:
|
|
|
42
42
|
|
|
43
43
|
field_to_remove = response_data.get("fieldToRemove")
|
|
44
44
|
|
|
45
|
-
print('response_data', response_data)
|
|
46
45
|
cursor = target_pool.cursor()
|
|
47
46
|
cursor.execute(response_data["query"])
|
|
48
47
|
query_result = cursor.fetchall()
|
|
49
|
-
print('testing', query_result)
|
|
50
48
|
names = [desc[0] for desc in cursor.description]
|
|
51
49
|
fields = [{"name": desc[0], "dataTypeID": desc[1]} for desc in cursor.description if desc[0] != field_to_remove]
|
|
52
|
-
rearrange_fields = any(field["dataTypeID"] == 1082 or field["name"] == "created_at" for field in fields)
|
|
53
|
-
if rearrange_fields:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
fields.sort(key=lambda x: x["dataTypeID"] != 1082)
|
|
50
|
+
# rearrange_fields = any(field["dataTypeID"] == 1082 or field["name"] == "created_at" for field in fields)
|
|
51
|
+
# if rearrange_fields:
|
|
52
|
+
# # Sort fields so that the entry with dataTypeID = 1082 or name "created_at" is the first element
|
|
53
|
+
# fields.sort(key=lambda x: (x["dataTypeID"] != 1082, x["name"] != "created_at"))
|
|
54
|
+
# fields.sort(key=lambda x: x["dataTypeID"] != 1082)
|
|
57
55
|
formatted_result = {
|
|
58
56
|
"fields": fields,
|
|
59
57
|
"rows": [dict(zip(names, row)) for row in query_result],
|
|
@@ -154,7 +152,7 @@ class Quill:
|
|
|
154
152
|
query_result = cursor.fetchall()
|
|
155
153
|
columns = [desc[0] for desc in cursor.description]
|
|
156
154
|
rows = [dict(zip(columns, row)) for row in query_result]
|
|
157
|
-
fields = [
|
|
155
|
+
fields = [{"name": desc[0], "dataTypeID": desc[1]} for desc in cursor.description if desc[0] != field_to_remove]
|
|
158
156
|
rows = [
|
|
159
157
|
{
|
|
160
158
|
key: value
|
|
@@ -167,4 +165,73 @@ class Quill:
|
|
|
167
165
|
return {**resp_data, "fields": fields, "rows": rows}
|
|
168
166
|
|
|
169
167
|
except Exception as err:
|
|
170
|
-
return {"error": str(err), "errorMessage": str(err) if err else ""}
|
|
168
|
+
return {"error": str(err), "errorMessage": str(err) if err else ""}
|
|
169
|
+
|
|
170
|
+
elif task == "view":
|
|
171
|
+
print('inside of view')
|
|
172
|
+
query = metadata.get("query", None)
|
|
173
|
+
name = metadata.get("name", None)
|
|
174
|
+
id = metadata.get("id", None)
|
|
175
|
+
deleted = metadata.get("deleted", None)
|
|
176
|
+
try:
|
|
177
|
+
if query and not deleted:
|
|
178
|
+
with target_pool.cursor() as cursor:
|
|
179
|
+
cursor.execute(query)
|
|
180
|
+
query_result = cursor.fetchall()
|
|
181
|
+
cursor.execute("select typname, oid, typarray from pg_type order by oid;")
|
|
182
|
+
types_query = cursor.fetchall()
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
if (id and deleted):
|
|
187
|
+
table_post = {"id": id, "deleted": deleted}
|
|
188
|
+
elif (id):
|
|
189
|
+
fields = [{"name": desc[0], "dataTypeID": desc[1]} for desc in cursor.description]
|
|
190
|
+
print('almost there')
|
|
191
|
+
table_post = {
|
|
192
|
+
"id": id,
|
|
193
|
+
"name": name,
|
|
194
|
+
"isVisible": True,
|
|
195
|
+
"viewQuery": query,
|
|
196
|
+
"columns": [
|
|
197
|
+
{
|
|
198
|
+
"fieldType": next((type[0] for type in types_query if field['dataTypeID'] == type[2]), None),
|
|
199
|
+
"name": field['name'],
|
|
200
|
+
"displayName": field['name'],
|
|
201
|
+
"isVisible": True
|
|
202
|
+
}
|
|
203
|
+
for field in fields
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
else:
|
|
207
|
+
fields = [{"name": desc[0], "dataTypeID": desc[1]} for desc in cursor.description if desc[0]]
|
|
208
|
+
table_post = {
|
|
209
|
+
"name": name,
|
|
210
|
+
"isVisible": True,
|
|
211
|
+
"viewQuery": query,
|
|
212
|
+
"columns": [
|
|
213
|
+
{
|
|
214
|
+
"fieldType": next((type[0] for type in types_query if field['dataTypeID'] == type[2]), None),
|
|
215
|
+
"name": field['name'],
|
|
216
|
+
"displayName": field['name'],
|
|
217
|
+
"isVisible": True
|
|
218
|
+
}
|
|
219
|
+
for field in fields
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
response = requests.post(
|
|
224
|
+
"http://localhost:8080/createtable",
|
|
225
|
+
json=table_post,
|
|
226
|
+
headers={"Authorization": f"Bearer {self.private_key}"}
|
|
227
|
+
)
|
|
228
|
+
response_data = response.json()
|
|
229
|
+
|
|
230
|
+
return response_data
|
|
231
|
+
|
|
232
|
+
except Exception as e:
|
|
233
|
+
print(f"An error occurred: {e}")
|
|
234
|
+
# Optionally, re-raise the error if you want it to be handled by an upper layer or if you want the program to exit
|
|
235
|
+
# raise
|
|
236
|
+
|
|
237
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|