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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quillsql
3
- Version: 0.6
3
+ Version: 0.8
4
4
  Summary: Quill SDK for Python.
5
5
  Home-page: https://github.com/quill-sql/quill-python
6
6
  Author: Quill
@@ -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
- # Sort fields so that the entry with dataTypeID = 1082 or name "created_at" is the first element
55
- fields.sort(key=lambda x: (x["dataTypeID"] != 1082, x["name"] != "created_at"))
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 = [column for column in columns if column != field_to_remove]
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
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quillsql
3
- Version: 0.6
3
+ Version: 0.8
4
4
  Summary: Quill SDK for Python.
5
5
  Home-page: https://github.com/quill-sql/quill-python
6
6
  Author: Quill
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="quillsql",
5
- version="0.6",
5
+ version="0.8",
6
6
  packages=find_packages(),
7
7
  install_requires=["psycopg2-binary", "requests"],
8
8
  author="Quill",
File without changes
File without changes
File without changes
File without changes