worqhat 3.4.0__py3-none-any.whl → 3.8.0__py3-none-any.whl
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.
- worqhat/__init__.py +3 -1
- worqhat/_base_client.py +12 -12
- worqhat/_client.py +21 -11
- worqhat/_compat.py +48 -48
- worqhat/_models.py +51 -45
- worqhat/_qs.py +7 -7
- worqhat/_types.py +53 -12
- worqhat/_utils/__init__.py +9 -2
- worqhat/_utils/_compat.py +45 -0
- worqhat/_utils/_datetime_parse.py +136 -0
- worqhat/_utils/_transform.py +13 -3
- worqhat/_utils/_typing.py +6 -1
- worqhat/_utils/_utils.py +4 -5
- worqhat/_version.py +1 -1
- worqhat/resources/__init__.py +14 -0
- worqhat/resources/client/__init__.py +33 -0
- worqhat/resources/client/client.py +102 -0
- worqhat/resources/client/storage.py +462 -0
- worqhat/resources/db/__init__.py +33 -0
- worqhat/resources/{db.py → db/db.py} +249 -36
- worqhat/resources/db/tables.py +389 -0
- worqhat/resources/flows.py +29 -23
- worqhat/resources/health.py +3 -3
- worqhat/types/__init__.py +2 -0
- worqhat/types/client/__init__.py +12 -0
- worqhat/types/client/storage_delete_file_by_id_response.py +18 -0
- worqhat/types/client/storage_retrieve_file_by_id_response.py +33 -0
- worqhat/types/client/storage_retrieve_file_by_path_params.py +12 -0
- worqhat/types/client/storage_retrieve_file_by_path_response.py +33 -0
- worqhat/types/client/storage_upload_file_params.py +17 -0
- worqhat/types/client/storage_upload_file_response.py +33 -0
- worqhat/types/db/__init__.py +10 -0
- worqhat/types/db/table_get_row_count_params.py +12 -0
- worqhat/types/db/table_get_row_count_response.py +15 -0
- worqhat/types/db/table_list_params.py +15 -0
- worqhat/types/db/table_list_response.py +26 -0
- worqhat/types/db/table_retrieve_schema_params.py +12 -0
- worqhat/types/db/table_retrieve_schema_response.py +29 -0
- worqhat/types/db_delete_records_params.py +6 -2
- worqhat/types/db_delete_records_response.py +2 -2
- worqhat/types/db_execute_batch_params.py +36 -0
- worqhat/types/db_execute_batch_response.py +27 -0
- worqhat/types/db_execute_query_params.py +8 -1
- worqhat/types/db_execute_query_response.py +2 -2
- worqhat/types/db_insert_record_params.py +6 -2
- worqhat/types/db_insert_record_response.py +2 -2
- worqhat/types/db_process_nl_query_params.py +10 -3
- worqhat/types/db_process_nl_query_response.py +2 -2
- worqhat/types/db_update_records_params.py +7 -3
- worqhat/types/db_update_records_response.py +2 -2
- worqhat/types/flow_trigger_with_payload_params.py +3 -2
- {worqhat-3.4.0.dist-info → worqhat-3.8.0.dist-info}/METADATA +4 -4
- worqhat-3.8.0.dist-info/RECORD +76 -0
- worqhat-3.4.0.dist-info/RECORD +0 -53
- {worqhat-3.4.0.dist-info → worqhat-3.8.0.dist-info}/WHEEL +0 -0
- {worqhat-3.4.0.dist-info → worqhat-3.8.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,36 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from typing import Dict, Iterable
|
|
6
|
+
from typing_extensions import Literal
|
|
7
|
+
|
|
5
8
|
import httpx
|
|
6
9
|
|
|
7
|
-
from
|
|
10
|
+
from .tables import (
|
|
11
|
+
TablesResource,
|
|
12
|
+
AsyncTablesResource,
|
|
13
|
+
TablesResourceWithRawResponse,
|
|
14
|
+
AsyncTablesResourceWithRawResponse,
|
|
15
|
+
TablesResourceWithStreamingResponse,
|
|
16
|
+
AsyncTablesResourceWithStreamingResponse,
|
|
17
|
+
)
|
|
18
|
+
from ...types import (
|
|
19
|
+
db_execute_batch_params,
|
|
8
20
|
db_execute_query_params,
|
|
9
21
|
db_insert_record_params,
|
|
10
22
|
db_delete_records_params,
|
|
11
23
|
db_update_records_params,
|
|
12
24
|
db_process_nl_query_params,
|
|
13
25
|
)
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from
|
|
18
|
-
from
|
|
26
|
+
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
27
|
+
from ..._utils import maybe_transform, async_maybe_transform
|
|
28
|
+
from ..._compat import cached_property
|
|
29
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
30
|
+
from ..._response import (
|
|
19
31
|
to_raw_response_wrapper,
|
|
20
32
|
to_streamed_response_wrapper,
|
|
21
33
|
async_to_raw_response_wrapper,
|
|
22
34
|
async_to_streamed_response_wrapper,
|
|
23
35
|
)
|
|
24
|
-
from
|
|
25
|
-
from
|
|
26
|
-
from
|
|
27
|
-
from
|
|
28
|
-
from
|
|
29
|
-
from
|
|
36
|
+
from ..._base_client import make_request_options
|
|
37
|
+
from ...types.db_execute_batch_response import DBExecuteBatchResponse
|
|
38
|
+
from ...types.db_execute_query_response import DBExecuteQueryResponse
|
|
39
|
+
from ...types.db_insert_record_response import DBInsertRecordResponse
|
|
40
|
+
from ...types.db_delete_records_response import DBDeleteRecordsResponse
|
|
41
|
+
from ...types.db_update_records_response import DBUpdateRecordsResponse
|
|
42
|
+
from ...types.db_process_nl_query_response import DBProcessNlQueryResponse
|
|
30
43
|
|
|
31
44
|
__all__ = ["DBResource", "AsyncDBResource"]
|
|
32
45
|
|
|
33
46
|
|
|
34
47
|
class DBResource(SyncAPIResource):
|
|
48
|
+
@cached_property
|
|
49
|
+
def tables(self) -> TablesResource:
|
|
50
|
+
return TablesResource(self._client)
|
|
51
|
+
|
|
35
52
|
@cached_property
|
|
36
53
|
def with_raw_response(self) -> DBResourceWithRawResponse:
|
|
37
54
|
"""
|
|
@@ -55,13 +72,14 @@ class DBResource(SyncAPIResource):
|
|
|
55
72
|
self,
|
|
56
73
|
*,
|
|
57
74
|
table: str,
|
|
58
|
-
where: object,
|
|
75
|
+
where: Dict[str, object],
|
|
76
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
59
77
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
60
78
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
61
79
|
extra_headers: Headers | None = None,
|
|
62
80
|
extra_query: Query | None = None,
|
|
63
81
|
extra_body: Body | None = None,
|
|
64
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
82
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
65
83
|
) -> DBDeleteRecordsResponse:
|
|
66
84
|
"""
|
|
67
85
|
Deletes records from the specified table that match the where conditions.
|
|
@@ -72,6 +90,8 @@ class DBResource(SyncAPIResource):
|
|
|
72
90
|
|
|
73
91
|
where: Where conditions
|
|
74
92
|
|
|
93
|
+
environment: Environment to delete from (development, staging, production)
|
|
94
|
+
|
|
75
95
|
extra_headers: Send extra headers
|
|
76
96
|
|
|
77
97
|
extra_query: Add additional query parameters to the request
|
|
@@ -86,6 +106,7 @@ class DBResource(SyncAPIResource):
|
|
|
86
106
|
{
|
|
87
107
|
"table": table,
|
|
88
108
|
"where": where,
|
|
109
|
+
"environment": environment,
|
|
89
110
|
},
|
|
90
111
|
db_delete_records_params.DBDeleteRecordsParams,
|
|
91
112
|
),
|
|
@@ -95,16 +116,67 @@ class DBResource(SyncAPIResource):
|
|
|
95
116
|
cast_to=DBDeleteRecordsResponse,
|
|
96
117
|
)
|
|
97
118
|
|
|
119
|
+
def execute_batch(
|
|
120
|
+
self,
|
|
121
|
+
*,
|
|
122
|
+
operations: Iterable[db_execute_batch_params.Operation],
|
|
123
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
124
|
+
transactional: bool | Omit = omit,
|
|
125
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
126
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
127
|
+
extra_headers: Headers | None = None,
|
|
128
|
+
extra_query: Query | None = None,
|
|
129
|
+
extra_body: Body | None = None,
|
|
130
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
131
|
+
) -> DBExecuteBatchResponse:
|
|
132
|
+
"""
|
|
133
|
+
Executes multiple database operations (queries, inserts, updates, deletes) in a
|
|
134
|
+
single transaction. If transactional is true, all operations will be rolled back
|
|
135
|
+
if any operation fails.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
operations: Array of database operations to execute
|
|
139
|
+
|
|
140
|
+
environment: Environment to execute operations in
|
|
141
|
+
|
|
142
|
+
transactional: Whether to execute all operations in a single transaction
|
|
143
|
+
|
|
144
|
+
extra_headers: Send extra headers
|
|
145
|
+
|
|
146
|
+
extra_query: Add additional query parameters to the request
|
|
147
|
+
|
|
148
|
+
extra_body: Add additional JSON properties to the request
|
|
149
|
+
|
|
150
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
151
|
+
"""
|
|
152
|
+
return self._post(
|
|
153
|
+
"/db/batch",
|
|
154
|
+
body=maybe_transform(
|
|
155
|
+
{
|
|
156
|
+
"operations": operations,
|
|
157
|
+
"environment": environment,
|
|
158
|
+
"transactional": transactional,
|
|
159
|
+
},
|
|
160
|
+
db_execute_batch_params.DBExecuteBatchParams,
|
|
161
|
+
),
|
|
162
|
+
options=make_request_options(
|
|
163
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
164
|
+
),
|
|
165
|
+
cast_to=DBExecuteBatchResponse,
|
|
166
|
+
)
|
|
167
|
+
|
|
98
168
|
def execute_query(
|
|
99
169
|
self,
|
|
100
170
|
*,
|
|
101
171
|
query: str,
|
|
172
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
173
|
+
params: Dict[str, object] | Omit = omit,
|
|
102
174
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
103
175
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
104
176
|
extra_headers: Headers | None = None,
|
|
105
177
|
extra_query: Query | None = None,
|
|
106
178
|
extra_body: Body | None = None,
|
|
107
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
179
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
108
180
|
) -> DBExecuteQueryResponse:
|
|
109
181
|
"""Executes a raw SQL query directly against ClickHouse (WorqDB).
|
|
110
182
|
|
|
@@ -115,6 +187,10 @@ class DBResource(SyncAPIResource):
|
|
|
115
187
|
Args:
|
|
116
188
|
query: SQL query to execute
|
|
117
189
|
|
|
190
|
+
environment: Environment to query (development, staging, production)
|
|
191
|
+
|
|
192
|
+
params: Optional query parameters
|
|
193
|
+
|
|
118
194
|
extra_headers: Send extra headers
|
|
119
195
|
|
|
120
196
|
extra_query: Add additional query parameters to the request
|
|
@@ -125,7 +201,14 @@ class DBResource(SyncAPIResource):
|
|
|
125
201
|
"""
|
|
126
202
|
return self._post(
|
|
127
203
|
"/db/query",
|
|
128
|
-
body=maybe_transform(
|
|
204
|
+
body=maybe_transform(
|
|
205
|
+
{
|
|
206
|
+
"query": query,
|
|
207
|
+
"environment": environment,
|
|
208
|
+
"params": params,
|
|
209
|
+
},
|
|
210
|
+
db_execute_query_params.DBExecuteQueryParams,
|
|
211
|
+
),
|
|
129
212
|
options=make_request_options(
|
|
130
213
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
131
214
|
),
|
|
@@ -135,14 +218,15 @@ class DBResource(SyncAPIResource):
|
|
|
135
218
|
def insert_record(
|
|
136
219
|
self,
|
|
137
220
|
*,
|
|
138
|
-
data: object,
|
|
221
|
+
data: Dict[str, object],
|
|
139
222
|
table: str,
|
|
223
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
140
224
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
141
225
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
142
226
|
extra_headers: Headers | None = None,
|
|
143
227
|
extra_query: Query | None = None,
|
|
144
228
|
extra_body: Body | None = None,
|
|
145
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
229
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
146
230
|
) -> DBInsertRecordResponse:
|
|
147
231
|
"""Inserts a new record into the specified table.
|
|
148
232
|
|
|
@@ -154,6 +238,8 @@ class DBResource(SyncAPIResource):
|
|
|
154
238
|
|
|
155
239
|
table: Table name to insert into
|
|
156
240
|
|
|
241
|
+
environment: Environment to insert into (development, staging, production)
|
|
242
|
+
|
|
157
243
|
extra_headers: Send extra headers
|
|
158
244
|
|
|
159
245
|
extra_query: Add additional query parameters to the request
|
|
@@ -168,6 +254,7 @@ class DBResource(SyncAPIResource):
|
|
|
168
254
|
{
|
|
169
255
|
"data": data,
|
|
170
256
|
"table": table,
|
|
257
|
+
"environment": environment,
|
|
171
258
|
},
|
|
172
259
|
db_insert_record_params.DBInsertRecordParams,
|
|
173
260
|
),
|
|
@@ -181,13 +268,15 @@ class DBResource(SyncAPIResource):
|
|
|
181
268
|
self,
|
|
182
269
|
*,
|
|
183
270
|
question: str,
|
|
184
|
-
|
|
271
|
+
table: str,
|
|
272
|
+
context: Dict[str, object] | Omit = omit,
|
|
273
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
185
274
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
186
275
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
187
276
|
extra_headers: Headers | None = None,
|
|
188
277
|
extra_query: Query | None = None,
|
|
189
278
|
extra_body: Body | None = None,
|
|
190
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
279
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
191
280
|
) -> DBProcessNlQueryResponse:
|
|
192
281
|
"""
|
|
193
282
|
Converts a natural language question into a SQL query and executes it.
|
|
@@ -196,7 +285,11 @@ class DBResource(SyncAPIResource):
|
|
|
196
285
|
Args:
|
|
197
286
|
question: Natural language question
|
|
198
287
|
|
|
199
|
-
|
|
288
|
+
table: Table name to query
|
|
289
|
+
|
|
290
|
+
context: Optional context for the query
|
|
291
|
+
|
|
292
|
+
environment: Environment to query (development, staging, production)
|
|
200
293
|
|
|
201
294
|
extra_headers: Send extra headers
|
|
202
295
|
|
|
@@ -211,7 +304,9 @@ class DBResource(SyncAPIResource):
|
|
|
211
304
|
body=maybe_transform(
|
|
212
305
|
{
|
|
213
306
|
"question": question,
|
|
307
|
+
"table": table,
|
|
214
308
|
"context": context,
|
|
309
|
+
"environment": environment,
|
|
215
310
|
},
|
|
216
311
|
db_process_nl_query_params.DBProcessNlQueryParams,
|
|
217
312
|
),
|
|
@@ -224,15 +319,16 @@ class DBResource(SyncAPIResource):
|
|
|
224
319
|
def update_records(
|
|
225
320
|
self,
|
|
226
321
|
*,
|
|
227
|
-
data: object,
|
|
322
|
+
data: Dict[str, object],
|
|
228
323
|
table: str,
|
|
229
|
-
where: object,
|
|
324
|
+
where: Dict[str, object],
|
|
325
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
230
326
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
231
327
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
232
328
|
extra_headers: Headers | None = None,
|
|
233
329
|
extra_query: Query | None = None,
|
|
234
330
|
extra_body: Body | None = None,
|
|
235
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
331
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
236
332
|
) -> DBUpdateRecordsResponse:
|
|
237
333
|
"""
|
|
238
334
|
Updates records in the specified table that match the where conditions.
|
|
@@ -245,6 +341,8 @@ class DBResource(SyncAPIResource):
|
|
|
245
341
|
|
|
246
342
|
where: Where conditions
|
|
247
343
|
|
|
344
|
+
environment: Environment to update in (development, staging, production)
|
|
345
|
+
|
|
248
346
|
extra_headers: Send extra headers
|
|
249
347
|
|
|
250
348
|
extra_query: Add additional query parameters to the request
|
|
@@ -260,6 +358,7 @@ class DBResource(SyncAPIResource):
|
|
|
260
358
|
"data": data,
|
|
261
359
|
"table": table,
|
|
262
360
|
"where": where,
|
|
361
|
+
"environment": environment,
|
|
263
362
|
},
|
|
264
363
|
db_update_records_params.DBUpdateRecordsParams,
|
|
265
364
|
),
|
|
@@ -271,6 +370,10 @@ class DBResource(SyncAPIResource):
|
|
|
271
370
|
|
|
272
371
|
|
|
273
372
|
class AsyncDBResource(AsyncAPIResource):
|
|
373
|
+
@cached_property
|
|
374
|
+
def tables(self) -> AsyncTablesResource:
|
|
375
|
+
return AsyncTablesResource(self._client)
|
|
376
|
+
|
|
274
377
|
@cached_property
|
|
275
378
|
def with_raw_response(self) -> AsyncDBResourceWithRawResponse:
|
|
276
379
|
"""
|
|
@@ -294,13 +397,14 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
294
397
|
self,
|
|
295
398
|
*,
|
|
296
399
|
table: str,
|
|
297
|
-
where: object,
|
|
400
|
+
where: Dict[str, object],
|
|
401
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
298
402
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
299
403
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
300
404
|
extra_headers: Headers | None = None,
|
|
301
405
|
extra_query: Query | None = None,
|
|
302
406
|
extra_body: Body | None = None,
|
|
303
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
407
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
304
408
|
) -> DBDeleteRecordsResponse:
|
|
305
409
|
"""
|
|
306
410
|
Deletes records from the specified table that match the where conditions.
|
|
@@ -311,6 +415,8 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
311
415
|
|
|
312
416
|
where: Where conditions
|
|
313
417
|
|
|
418
|
+
environment: Environment to delete from (development, staging, production)
|
|
419
|
+
|
|
314
420
|
extra_headers: Send extra headers
|
|
315
421
|
|
|
316
422
|
extra_query: Add additional query parameters to the request
|
|
@@ -325,6 +431,7 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
325
431
|
{
|
|
326
432
|
"table": table,
|
|
327
433
|
"where": where,
|
|
434
|
+
"environment": environment,
|
|
328
435
|
},
|
|
329
436
|
db_delete_records_params.DBDeleteRecordsParams,
|
|
330
437
|
),
|
|
@@ -334,16 +441,67 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
334
441
|
cast_to=DBDeleteRecordsResponse,
|
|
335
442
|
)
|
|
336
443
|
|
|
444
|
+
async def execute_batch(
|
|
445
|
+
self,
|
|
446
|
+
*,
|
|
447
|
+
operations: Iterable[db_execute_batch_params.Operation],
|
|
448
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
449
|
+
transactional: bool | Omit = omit,
|
|
450
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
451
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
452
|
+
extra_headers: Headers | None = None,
|
|
453
|
+
extra_query: Query | None = None,
|
|
454
|
+
extra_body: Body | None = None,
|
|
455
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
456
|
+
) -> DBExecuteBatchResponse:
|
|
457
|
+
"""
|
|
458
|
+
Executes multiple database operations (queries, inserts, updates, deletes) in a
|
|
459
|
+
single transaction. If transactional is true, all operations will be rolled back
|
|
460
|
+
if any operation fails.
|
|
461
|
+
|
|
462
|
+
Args:
|
|
463
|
+
operations: Array of database operations to execute
|
|
464
|
+
|
|
465
|
+
environment: Environment to execute operations in
|
|
466
|
+
|
|
467
|
+
transactional: Whether to execute all operations in a single transaction
|
|
468
|
+
|
|
469
|
+
extra_headers: Send extra headers
|
|
470
|
+
|
|
471
|
+
extra_query: Add additional query parameters to the request
|
|
472
|
+
|
|
473
|
+
extra_body: Add additional JSON properties to the request
|
|
474
|
+
|
|
475
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
476
|
+
"""
|
|
477
|
+
return await self._post(
|
|
478
|
+
"/db/batch",
|
|
479
|
+
body=await async_maybe_transform(
|
|
480
|
+
{
|
|
481
|
+
"operations": operations,
|
|
482
|
+
"environment": environment,
|
|
483
|
+
"transactional": transactional,
|
|
484
|
+
},
|
|
485
|
+
db_execute_batch_params.DBExecuteBatchParams,
|
|
486
|
+
),
|
|
487
|
+
options=make_request_options(
|
|
488
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
489
|
+
),
|
|
490
|
+
cast_to=DBExecuteBatchResponse,
|
|
491
|
+
)
|
|
492
|
+
|
|
337
493
|
async def execute_query(
|
|
338
494
|
self,
|
|
339
495
|
*,
|
|
340
496
|
query: str,
|
|
497
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
498
|
+
params: Dict[str, object] | Omit = omit,
|
|
341
499
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
342
500
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
343
501
|
extra_headers: Headers | None = None,
|
|
344
502
|
extra_query: Query | None = None,
|
|
345
503
|
extra_body: Body | None = None,
|
|
346
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
504
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
347
505
|
) -> DBExecuteQueryResponse:
|
|
348
506
|
"""Executes a raw SQL query directly against ClickHouse (WorqDB).
|
|
349
507
|
|
|
@@ -354,6 +512,10 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
354
512
|
Args:
|
|
355
513
|
query: SQL query to execute
|
|
356
514
|
|
|
515
|
+
environment: Environment to query (development, staging, production)
|
|
516
|
+
|
|
517
|
+
params: Optional query parameters
|
|
518
|
+
|
|
357
519
|
extra_headers: Send extra headers
|
|
358
520
|
|
|
359
521
|
extra_query: Add additional query parameters to the request
|
|
@@ -364,7 +526,14 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
364
526
|
"""
|
|
365
527
|
return await self._post(
|
|
366
528
|
"/db/query",
|
|
367
|
-
body=await async_maybe_transform(
|
|
529
|
+
body=await async_maybe_transform(
|
|
530
|
+
{
|
|
531
|
+
"query": query,
|
|
532
|
+
"environment": environment,
|
|
533
|
+
"params": params,
|
|
534
|
+
},
|
|
535
|
+
db_execute_query_params.DBExecuteQueryParams,
|
|
536
|
+
),
|
|
368
537
|
options=make_request_options(
|
|
369
538
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
370
539
|
),
|
|
@@ -374,14 +543,15 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
374
543
|
async def insert_record(
|
|
375
544
|
self,
|
|
376
545
|
*,
|
|
377
|
-
data: object,
|
|
546
|
+
data: Dict[str, object],
|
|
378
547
|
table: str,
|
|
548
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
379
549
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
380
550
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
381
551
|
extra_headers: Headers | None = None,
|
|
382
552
|
extra_query: Query | None = None,
|
|
383
553
|
extra_body: Body | None = None,
|
|
384
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
554
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
385
555
|
) -> DBInsertRecordResponse:
|
|
386
556
|
"""Inserts a new record into the specified table.
|
|
387
557
|
|
|
@@ -393,6 +563,8 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
393
563
|
|
|
394
564
|
table: Table name to insert into
|
|
395
565
|
|
|
566
|
+
environment: Environment to insert into (development, staging, production)
|
|
567
|
+
|
|
396
568
|
extra_headers: Send extra headers
|
|
397
569
|
|
|
398
570
|
extra_query: Add additional query parameters to the request
|
|
@@ -407,6 +579,7 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
407
579
|
{
|
|
408
580
|
"data": data,
|
|
409
581
|
"table": table,
|
|
582
|
+
"environment": environment,
|
|
410
583
|
},
|
|
411
584
|
db_insert_record_params.DBInsertRecordParams,
|
|
412
585
|
),
|
|
@@ -420,13 +593,15 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
420
593
|
self,
|
|
421
594
|
*,
|
|
422
595
|
question: str,
|
|
423
|
-
|
|
596
|
+
table: str,
|
|
597
|
+
context: Dict[str, object] | Omit = omit,
|
|
598
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
424
599
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
425
600
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
426
601
|
extra_headers: Headers | None = None,
|
|
427
602
|
extra_query: Query | None = None,
|
|
428
603
|
extra_body: Body | None = None,
|
|
429
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
604
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
430
605
|
) -> DBProcessNlQueryResponse:
|
|
431
606
|
"""
|
|
432
607
|
Converts a natural language question into a SQL query and executes it.
|
|
@@ -435,7 +610,11 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
435
610
|
Args:
|
|
436
611
|
question: Natural language question
|
|
437
612
|
|
|
438
|
-
|
|
613
|
+
table: Table name to query
|
|
614
|
+
|
|
615
|
+
context: Optional context for the query
|
|
616
|
+
|
|
617
|
+
environment: Environment to query (development, staging, production)
|
|
439
618
|
|
|
440
619
|
extra_headers: Send extra headers
|
|
441
620
|
|
|
@@ -450,7 +629,9 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
450
629
|
body=await async_maybe_transform(
|
|
451
630
|
{
|
|
452
631
|
"question": question,
|
|
632
|
+
"table": table,
|
|
453
633
|
"context": context,
|
|
634
|
+
"environment": environment,
|
|
454
635
|
},
|
|
455
636
|
db_process_nl_query_params.DBProcessNlQueryParams,
|
|
456
637
|
),
|
|
@@ -463,15 +644,16 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
463
644
|
async def update_records(
|
|
464
645
|
self,
|
|
465
646
|
*,
|
|
466
|
-
data: object,
|
|
647
|
+
data: Dict[str, object],
|
|
467
648
|
table: str,
|
|
468
|
-
where: object,
|
|
649
|
+
where: Dict[str, object],
|
|
650
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
469
651
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
470
652
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
471
653
|
extra_headers: Headers | None = None,
|
|
472
654
|
extra_query: Query | None = None,
|
|
473
655
|
extra_body: Body | None = None,
|
|
474
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
656
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
475
657
|
) -> DBUpdateRecordsResponse:
|
|
476
658
|
"""
|
|
477
659
|
Updates records in the specified table that match the where conditions.
|
|
@@ -484,6 +666,8 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
484
666
|
|
|
485
667
|
where: Where conditions
|
|
486
668
|
|
|
669
|
+
environment: Environment to update in (development, staging, production)
|
|
670
|
+
|
|
487
671
|
extra_headers: Send extra headers
|
|
488
672
|
|
|
489
673
|
extra_query: Add additional query parameters to the request
|
|
@@ -499,6 +683,7 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
499
683
|
"data": data,
|
|
500
684
|
"table": table,
|
|
501
685
|
"where": where,
|
|
686
|
+
"environment": environment,
|
|
502
687
|
},
|
|
503
688
|
db_update_records_params.DBUpdateRecordsParams,
|
|
504
689
|
),
|
|
@@ -516,6 +701,9 @@ class DBResourceWithRawResponse:
|
|
|
516
701
|
self.delete_records = to_raw_response_wrapper(
|
|
517
702
|
db.delete_records,
|
|
518
703
|
)
|
|
704
|
+
self.execute_batch = to_raw_response_wrapper(
|
|
705
|
+
db.execute_batch,
|
|
706
|
+
)
|
|
519
707
|
self.execute_query = to_raw_response_wrapper(
|
|
520
708
|
db.execute_query,
|
|
521
709
|
)
|
|
@@ -529,6 +717,10 @@ class DBResourceWithRawResponse:
|
|
|
529
717
|
db.update_records,
|
|
530
718
|
)
|
|
531
719
|
|
|
720
|
+
@cached_property
|
|
721
|
+
def tables(self) -> TablesResourceWithRawResponse:
|
|
722
|
+
return TablesResourceWithRawResponse(self._db.tables)
|
|
723
|
+
|
|
532
724
|
|
|
533
725
|
class AsyncDBResourceWithRawResponse:
|
|
534
726
|
def __init__(self, db: AsyncDBResource) -> None:
|
|
@@ -537,6 +729,9 @@ class AsyncDBResourceWithRawResponse:
|
|
|
537
729
|
self.delete_records = async_to_raw_response_wrapper(
|
|
538
730
|
db.delete_records,
|
|
539
731
|
)
|
|
732
|
+
self.execute_batch = async_to_raw_response_wrapper(
|
|
733
|
+
db.execute_batch,
|
|
734
|
+
)
|
|
540
735
|
self.execute_query = async_to_raw_response_wrapper(
|
|
541
736
|
db.execute_query,
|
|
542
737
|
)
|
|
@@ -550,6 +745,10 @@ class AsyncDBResourceWithRawResponse:
|
|
|
550
745
|
db.update_records,
|
|
551
746
|
)
|
|
552
747
|
|
|
748
|
+
@cached_property
|
|
749
|
+
def tables(self) -> AsyncTablesResourceWithRawResponse:
|
|
750
|
+
return AsyncTablesResourceWithRawResponse(self._db.tables)
|
|
751
|
+
|
|
553
752
|
|
|
554
753
|
class DBResourceWithStreamingResponse:
|
|
555
754
|
def __init__(self, db: DBResource) -> None:
|
|
@@ -558,6 +757,9 @@ class DBResourceWithStreamingResponse:
|
|
|
558
757
|
self.delete_records = to_streamed_response_wrapper(
|
|
559
758
|
db.delete_records,
|
|
560
759
|
)
|
|
760
|
+
self.execute_batch = to_streamed_response_wrapper(
|
|
761
|
+
db.execute_batch,
|
|
762
|
+
)
|
|
561
763
|
self.execute_query = to_streamed_response_wrapper(
|
|
562
764
|
db.execute_query,
|
|
563
765
|
)
|
|
@@ -571,6 +773,10 @@ class DBResourceWithStreamingResponse:
|
|
|
571
773
|
db.update_records,
|
|
572
774
|
)
|
|
573
775
|
|
|
776
|
+
@cached_property
|
|
777
|
+
def tables(self) -> TablesResourceWithStreamingResponse:
|
|
778
|
+
return TablesResourceWithStreamingResponse(self._db.tables)
|
|
779
|
+
|
|
574
780
|
|
|
575
781
|
class AsyncDBResourceWithStreamingResponse:
|
|
576
782
|
def __init__(self, db: AsyncDBResource) -> None:
|
|
@@ -579,6 +785,9 @@ class AsyncDBResourceWithStreamingResponse:
|
|
|
579
785
|
self.delete_records = async_to_streamed_response_wrapper(
|
|
580
786
|
db.delete_records,
|
|
581
787
|
)
|
|
788
|
+
self.execute_batch = async_to_streamed_response_wrapper(
|
|
789
|
+
db.execute_batch,
|
|
790
|
+
)
|
|
582
791
|
self.execute_query = async_to_streamed_response_wrapper(
|
|
583
792
|
db.execute_query,
|
|
584
793
|
)
|
|
@@ -591,3 +800,7 @@ class AsyncDBResourceWithStreamingResponse:
|
|
|
591
800
|
self.update_records = async_to_streamed_response_wrapper(
|
|
592
801
|
db.update_records,
|
|
593
802
|
)
|
|
803
|
+
|
|
804
|
+
@cached_property
|
|
805
|
+
def tables(self) -> AsyncTablesResourceWithStreamingResponse:
|
|
806
|
+
return AsyncTablesResourceWithStreamingResponse(self._db.tables)
|