MindsDB 25.8.3.0__py3-none-any.whl → 25.9.1.1__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.
Potentially problematic release.
This version of MindsDB might be problematic. Click here for more details.
- mindsdb/__about__.py +1 -1
- mindsdb/__main__.py +3 -45
- mindsdb/api/a2a/__init__.py +52 -0
- mindsdb/api/a2a/agent.py +11 -12
- mindsdb/api/a2a/common/server/server.py +17 -36
- mindsdb/api/a2a/common/server/task_manager.py +14 -28
- mindsdb/api/a2a/task_manager.py +20 -21
- mindsdb/api/a2a/utils.py +1 -1
- mindsdb/api/common/middleware.py +106 -0
- mindsdb/api/executor/utilities/mysql_to_duckdb_functions.py +466 -18
- mindsdb/api/executor/utilities/sql.py +9 -31
- mindsdb/api/http/initialize.py +34 -43
- mindsdb/api/http/namespaces/auth.py +6 -14
- mindsdb/api/http/namespaces/config.py +0 -2
- mindsdb/api/http/namespaces/default.py +74 -106
- mindsdb/api/http/namespaces/file.py +9 -3
- mindsdb/api/http/namespaces/handlers.py +77 -87
- mindsdb/api/http/start.py +29 -47
- mindsdb/api/litellm/start.py +11 -10
- mindsdb/api/mcp/__init__.py +165 -0
- mindsdb/api/mysql/mysql_proxy/mysql_proxy.py +33 -64
- mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +86 -85
- mindsdb/integrations/handlers/autogluon_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/autosklearn_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/crate_handler/crate_handler.py +3 -7
- mindsdb/integrations/handlers/derby_handler/derby_handler.py +32 -34
- mindsdb/integrations/handlers/documentdb_handler/requirements.txt +1 -0
- mindsdb/integrations/handlers/dummy_data_handler/dummy_data_handler.py +12 -13
- mindsdb/integrations/handlers/flaml_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/google_books_handler/google_books_handler.py +45 -44
- mindsdb/integrations/handlers/google_calendar_handler/google_calendar_handler.py +101 -95
- mindsdb/integrations/handlers/google_content_shopping_handler/google_content_shopping_handler.py +129 -129
- mindsdb/integrations/handlers/google_fit_handler/google_fit_handler.py +59 -43
- mindsdb/integrations/handlers/google_search_handler/google_search_handler.py +38 -39
- mindsdb/integrations/handlers/informix_handler/informix_handler.py +5 -18
- mindsdb/integrations/handlers/lightfm_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/lightwood_handler/requirements.txt +4 -4
- mindsdb/integrations/handlers/maxdb_handler/maxdb_handler.py +22 -28
- mindsdb/integrations/handlers/monetdb_handler/monetdb_handler.py +3 -7
- mindsdb/integrations/handlers/mongodb_handler/mongodb_handler.py +53 -67
- mindsdb/integrations/handlers/mongodb_handler/requirements.txt +1 -0
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_ast.py +43 -68
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_parser.py +17 -25
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_query.py +10 -16
- mindsdb/integrations/handlers/mongodb_handler/utils/mongodb_render.py +43 -69
- mindsdb/integrations/handlers/tpot_handler/requirements.txt +1 -1
- mindsdb/integrations/libs/base.py +1 -1
- mindsdb/integrations/libs/llm/config.py +15 -0
- mindsdb/integrations/libs/llm/utils.py +15 -0
- mindsdb/interfaces/agents/constants.py +1 -0
- mindsdb/interfaces/agents/langchain_agent.py +4 -0
- mindsdb/interfaces/agents/providers.py +20 -0
- mindsdb/interfaces/knowledge_base/controller.py +25 -7
- mindsdb/utilities/config.py +15 -158
- mindsdb/utilities/log.py +0 -25
- mindsdb/utilities/render/sqlalchemy_render.py +7 -1
- mindsdb/utilities/starters.py +0 -39
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/METADATA +269 -267
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/RECORD +62 -105
- mindsdb/api/a2a/__main__.py +0 -144
- mindsdb/api/a2a/run_a2a.py +0 -86
- mindsdb/api/common/check_auth.py +0 -42
- mindsdb/api/http/gunicorn_wrapper.py +0 -17
- mindsdb/api/mcp/start.py +0 -205
- mindsdb/api/mongo/__init__.py +0 -0
- mindsdb/api/mongo/classes/__init__.py +0 -5
- mindsdb/api/mongo/classes/query_sql.py +0 -19
- mindsdb/api/mongo/classes/responder.py +0 -45
- mindsdb/api/mongo/classes/responder_collection.py +0 -34
- mindsdb/api/mongo/classes/scram.py +0 -86
- mindsdb/api/mongo/classes/session.py +0 -23
- mindsdb/api/mongo/functions/__init__.py +0 -19
- mindsdb/api/mongo/responders/__init__.py +0 -73
- mindsdb/api/mongo/responders/add_shard.py +0 -13
- mindsdb/api/mongo/responders/aggregate.py +0 -90
- mindsdb/api/mongo/responders/buildinfo.py +0 -17
- mindsdb/api/mongo/responders/coll_stats.py +0 -63
- mindsdb/api/mongo/responders/company_id.py +0 -25
- mindsdb/api/mongo/responders/connection_status.py +0 -22
- mindsdb/api/mongo/responders/count.py +0 -21
- mindsdb/api/mongo/responders/db_stats.py +0 -32
- mindsdb/api/mongo/responders/delete.py +0 -105
- mindsdb/api/mongo/responders/describe.py +0 -23
- mindsdb/api/mongo/responders/end_sessions.py +0 -13
- mindsdb/api/mongo/responders/find.py +0 -175
- mindsdb/api/mongo/responders/get_cmd_line_opts.py +0 -18
- mindsdb/api/mongo/responders/get_free_monitoring_status.py +0 -14
- mindsdb/api/mongo/responders/get_parameter.py +0 -23
- mindsdb/api/mongo/responders/getlog.py +0 -14
- mindsdb/api/mongo/responders/host_info.py +0 -28
- mindsdb/api/mongo/responders/insert.py +0 -270
- mindsdb/api/mongo/responders/is_master.py +0 -20
- mindsdb/api/mongo/responders/is_master_lower.py +0 -13
- mindsdb/api/mongo/responders/list_collections.py +0 -55
- mindsdb/api/mongo/responders/list_databases.py +0 -37
- mindsdb/api/mongo/responders/list_indexes.py +0 -22
- mindsdb/api/mongo/responders/ping.py +0 -13
- mindsdb/api/mongo/responders/recv_chunk_start.py +0 -13
- mindsdb/api/mongo/responders/replsetgetstatus.py +0 -13
- mindsdb/api/mongo/responders/sasl_continue.py +0 -34
- mindsdb/api/mongo/responders/sasl_start.py +0 -33
- mindsdb/api/mongo/responders/update_range_deletions.py +0 -12
- mindsdb/api/mongo/responders/whatsmyuri.py +0 -18
- mindsdb/api/mongo/server.py +0 -388
- mindsdb/api/mongo/start.py +0 -15
- mindsdb/api/mongo/utilities/__init__.py +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/WHEEL +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/licenses/LICENSE +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/top_level.txt +0 -0
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'hostInfo': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
# NOTE answer is not full, but looks like this info is enough
|
|
9
|
-
result = {
|
|
10
|
-
'system': {
|
|
11
|
-
'cpuAddrSize': 64,
|
|
12
|
-
'memSizeMB': 15951,
|
|
13
|
-
'numCores': 4,
|
|
14
|
-
'cpuArch': "x86_64",
|
|
15
|
-
'numaEnabled': False
|
|
16
|
-
},
|
|
17
|
-
'os': {
|
|
18
|
-
'type': "Linux",
|
|
19
|
-
'name': "Ubuntu",
|
|
20
|
-
'version': "20.04"
|
|
21
|
-
},
|
|
22
|
-
'extra': {
|
|
23
|
-
},
|
|
24
|
-
'ok': 1
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
responder = Responce()
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
from mindsdb_sql_parser.ast import Constant, Identifier, Insert, OrderBy, TableColumn
|
|
3
|
-
from mindsdb_sql_parser.ast.mindsdb import (
|
|
4
|
-
CreateJob,
|
|
5
|
-
CreateMLEngine,
|
|
6
|
-
CreatePredictor,
|
|
7
|
-
FinetunePredictor,
|
|
8
|
-
RetrainPredictor,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
import mindsdb.api.mongo.functions as helpers
|
|
12
|
-
from mindsdb.api.mongo.classes import Responder
|
|
13
|
-
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
14
|
-
from mindsdb.api.mongo.responders.aggregate import aggregate_to_ast
|
|
15
|
-
from mindsdb.api.mongo.responders.find import find_to_ast
|
|
16
|
-
from mindsdb.api.mongo.utilities.mongodb_parser import MongodbParser
|
|
17
|
-
from mindsdb.integrations.libs.response import HandlerStatusResponse
|
|
18
|
-
from mindsdb.utilities import log
|
|
19
|
-
from mindsdb.utilities.config import config
|
|
20
|
-
|
|
21
|
-
logger = log.getLogger(__name__)
|
|
22
|
-
default_project = config.get("default_project")
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class Responce(Responder):
|
|
26
|
-
when = {"insert": helpers.is_true}
|
|
27
|
-
|
|
28
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
29
|
-
try:
|
|
30
|
-
res = self._result(query, request_env, mindsdb_env)
|
|
31
|
-
except Exception as e:
|
|
32
|
-
logger.error(e)
|
|
33
|
-
res = {
|
|
34
|
-
"n": 0,
|
|
35
|
-
"writeErrors": [{"index": 0, "code": 0, "errmsg": str(e)}],
|
|
36
|
-
"ok": 1,
|
|
37
|
-
}
|
|
38
|
-
return res
|
|
39
|
-
|
|
40
|
-
def _insert_database(self, query, request_env, mindsdb_env):
|
|
41
|
-
|
|
42
|
-
for doc in query["documents"]:
|
|
43
|
-
if "_id" in doc:
|
|
44
|
-
del doc["_id"]
|
|
45
|
-
for field in ("name", "engine", "connection_args"):
|
|
46
|
-
if field not in doc:
|
|
47
|
-
raise Exception(f"'{field}' must be specified")
|
|
48
|
-
|
|
49
|
-
status = HandlerStatusResponse(success=False)
|
|
50
|
-
try:
|
|
51
|
-
handler = mindsdb_env["integration_controller"].create_tmp_handler(
|
|
52
|
-
name=doc['name'],
|
|
53
|
-
engine=doc["engine"],
|
|
54
|
-
connection_args=doc["connection_args"]
|
|
55
|
-
)
|
|
56
|
-
status = handler.check_connection()
|
|
57
|
-
except Exception as e:
|
|
58
|
-
status.error_message = str(e)
|
|
59
|
-
|
|
60
|
-
if status.success is False:
|
|
61
|
-
raise Exception(f"Can't connect to db: {status.error_message}")
|
|
62
|
-
|
|
63
|
-
integration = mindsdb_env["integration_controller"].get(doc["name"])
|
|
64
|
-
if integration is not None:
|
|
65
|
-
raise Exception(f"Database '{doc['name']}' already exists.")
|
|
66
|
-
|
|
67
|
-
for doc in query["documents"]:
|
|
68
|
-
mindsdb_env["integration_controller"].add(
|
|
69
|
-
doc["name"], doc["engine"], doc["connection_args"]
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
def _insert_model(self, query, request_env, mindsdb_env):
|
|
73
|
-
predictors_columns = [
|
|
74
|
-
"name",
|
|
75
|
-
"status",
|
|
76
|
-
"accuracy",
|
|
77
|
-
"predict",
|
|
78
|
-
"select_data_query",
|
|
79
|
-
"training_options",
|
|
80
|
-
"connection",
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
if len(query["documents"]) != 1:
|
|
84
|
-
raise Exception("Must be inserted just one predictor at time")
|
|
85
|
-
|
|
86
|
-
for doc in query["documents"]:
|
|
87
|
-
if "_id" in doc:
|
|
88
|
-
del doc["_id"]
|
|
89
|
-
|
|
90
|
-
action = doc.pop("action", "create").lower()
|
|
91
|
-
|
|
92
|
-
bad_columns = [x for x in doc if x not in predictors_columns]
|
|
93
|
-
if len(bad_columns) > 0:
|
|
94
|
-
raise Exception(
|
|
95
|
-
f"Is no possible insert this columns to 'predictors' collection: {', '.join(bad_columns)}"
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
if "name" not in doc:
|
|
99
|
-
raise Exception("Please, specify 'name' field")
|
|
100
|
-
|
|
101
|
-
if "predict" not in doc:
|
|
102
|
-
predict = None
|
|
103
|
-
if action == "create":
|
|
104
|
-
raise Exception("Please, specify 'predict' field")
|
|
105
|
-
else:
|
|
106
|
-
predict = doc["predict"]
|
|
107
|
-
if not isinstance(predict, list):
|
|
108
|
-
predict = [Identifier(x.strip()) for x in predict.split(",")]
|
|
109
|
-
|
|
110
|
-
order_by = None
|
|
111
|
-
group_by = None
|
|
112
|
-
ts_settings = {}
|
|
113
|
-
|
|
114
|
-
kwargs = doc.get("training_options", {})
|
|
115
|
-
|
|
116
|
-
if "timeseries_settings" in kwargs:
|
|
117
|
-
ts_settings = kwargs.pop("timeseries_settings")
|
|
118
|
-
|
|
119
|
-
# mongo shell client sends int as float. need to convert it to int
|
|
120
|
-
for key in ("window", "horizon"):
|
|
121
|
-
val = ts_settings.get(key)
|
|
122
|
-
if val is not None:
|
|
123
|
-
ts_settings[key] = int(val)
|
|
124
|
-
|
|
125
|
-
if "order_by" in ts_settings:
|
|
126
|
-
order_by = ts_settings["order_by"]
|
|
127
|
-
if not isinstance(order_by, list):
|
|
128
|
-
order_by = [order_by]
|
|
129
|
-
|
|
130
|
-
order_by = [OrderBy(Identifier(x)) for x in order_by]
|
|
131
|
-
if "group_by" in ts_settings:
|
|
132
|
-
group_by = [Identifier(x) for x in ts_settings.get("group_by", [])]
|
|
133
|
-
|
|
134
|
-
using = dict(kwargs)
|
|
135
|
-
|
|
136
|
-
select_data_query = doc.get("select_data_query")
|
|
137
|
-
integration_name = None
|
|
138
|
-
if "connection" in doc:
|
|
139
|
-
integration_name = Identifier(doc["connection"])
|
|
140
|
-
|
|
141
|
-
Class = CreatePredictor
|
|
142
|
-
if action == "retrain":
|
|
143
|
-
Class = RetrainPredictor
|
|
144
|
-
elif action == "finetune":
|
|
145
|
-
Class = FinetunePredictor
|
|
146
|
-
|
|
147
|
-
create_predictor_ast = Class(
|
|
148
|
-
name=Identifier(f"{request_env['database']}.{doc['name']}"),
|
|
149
|
-
integration_name=integration_name,
|
|
150
|
-
query_str=select_data_query,
|
|
151
|
-
targets=predict,
|
|
152
|
-
order_by=order_by,
|
|
153
|
-
group_by=group_by,
|
|
154
|
-
window=ts_settings.get("window"),
|
|
155
|
-
horizon=ts_settings.get("horizon"),
|
|
156
|
-
using=using,
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
run_sql_command(request_env, create_predictor_ast)
|
|
160
|
-
|
|
161
|
-
def _insert_job(self, query, request_env, mindsdb_env):
|
|
162
|
-
for doc in query["documents"]:
|
|
163
|
-
|
|
164
|
-
query_str = doc["query"]
|
|
165
|
-
# try parse as mongo
|
|
166
|
-
parser = MongodbParser()
|
|
167
|
-
try:
|
|
168
|
-
mql = parser.from_string(query_str)
|
|
169
|
-
|
|
170
|
-
method = mql.pipeline[0]["method"]
|
|
171
|
-
if method == "find":
|
|
172
|
-
args = mql.pipeline[0]["args"]
|
|
173
|
-
projection = None
|
|
174
|
-
if len(args) > 1:
|
|
175
|
-
projection = args[1]
|
|
176
|
-
query = {
|
|
177
|
-
"find": mql.collection,
|
|
178
|
-
"filter": args[0],
|
|
179
|
-
"projection": projection,
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
for step in mql.pipeline[1:]:
|
|
183
|
-
if step["method"] == "limit":
|
|
184
|
-
query["limit"] = step["args"][0]
|
|
185
|
-
if step["method"] == "skip":
|
|
186
|
-
query["skip"] = step["args"][0]
|
|
187
|
-
if step["method"] == "sort":
|
|
188
|
-
query["sort"] = step["args"][0]
|
|
189
|
-
# TODO implement group modifiers
|
|
190
|
-
ast_query = find_to_ast(
|
|
191
|
-
query, request_env.get("database", default_project)
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
# to string
|
|
195
|
-
query_str = ast_query.to_string()
|
|
196
|
-
elif method == "aggregate":
|
|
197
|
-
query = {
|
|
198
|
-
"aggregate": mql.collection,
|
|
199
|
-
"pipeline": mql.pipeline[0]["args"][0],
|
|
200
|
-
}
|
|
201
|
-
ast_query = aggregate_to_ast(
|
|
202
|
-
query, request_env.get("database", default_project)
|
|
203
|
-
)
|
|
204
|
-
query_str = ast_query.to_string()
|
|
205
|
-
except Exception:
|
|
206
|
-
# keep query
|
|
207
|
-
pass
|
|
208
|
-
|
|
209
|
-
repeat_str = doc.get("schedule_str").lower().lstrip("every ")
|
|
210
|
-
|
|
211
|
-
ast_query = CreateJob(
|
|
212
|
-
name=Identifier(doc["name"]),
|
|
213
|
-
start_str=doc.get("start_at"),
|
|
214
|
-
end_str=doc.get("end_at"),
|
|
215
|
-
query_str=query_str,
|
|
216
|
-
repeat_str=repeat_str,
|
|
217
|
-
)
|
|
218
|
-
run_sql_command(request_env, ast_query)
|
|
219
|
-
|
|
220
|
-
def _insert_ml_engine(self, query, request_env, mindsdb_env):
|
|
221
|
-
for doc in query["documents"]:
|
|
222
|
-
|
|
223
|
-
ast_query = CreateMLEngine(
|
|
224
|
-
name=Identifier(doc["name"]),
|
|
225
|
-
handler=doc["handler"],
|
|
226
|
-
params=doc.get("params"),
|
|
227
|
-
)
|
|
228
|
-
|
|
229
|
-
run_sql_command(request_env, ast_query)
|
|
230
|
-
|
|
231
|
-
def _result(self, query, request_env, mindsdb_env):
|
|
232
|
-
table = query["insert"]
|
|
233
|
-
|
|
234
|
-
if table == "databases":
|
|
235
|
-
self._insert_database(query, request_env, mindsdb_env)
|
|
236
|
-
|
|
237
|
-
elif table in ["predictors", "models"]:
|
|
238
|
-
self._insert_model(query, request_env, mindsdb_env)
|
|
239
|
-
|
|
240
|
-
elif table == "jobs":
|
|
241
|
-
self._insert_job(query, request_env, mindsdb_env)
|
|
242
|
-
|
|
243
|
-
elif table == "ml_engines":
|
|
244
|
-
self._insert_ml_engine(query, request_env, mindsdb_env)
|
|
245
|
-
|
|
246
|
-
else:
|
|
247
|
-
# regular insert
|
|
248
|
-
|
|
249
|
-
df = pd.DataFrame(query["documents"])
|
|
250
|
-
if "_id" in df.columns:
|
|
251
|
-
df = df.drop("_id", axis=1)
|
|
252
|
-
|
|
253
|
-
data = df.to_dict("split")
|
|
254
|
-
values = []
|
|
255
|
-
for row in data["data"]:
|
|
256
|
-
values.append([Constant(i) for i in row])
|
|
257
|
-
ast_query = Insert(
|
|
258
|
-
table=Identifier(table),
|
|
259
|
-
columns=[TableColumn(c) for c in data["columns"]],
|
|
260
|
-
values=values,
|
|
261
|
-
)
|
|
262
|
-
|
|
263
|
-
run_sql_command(request_env, ast_query)
|
|
264
|
-
|
|
265
|
-
result = {"n": len(query["documents"]), "ok": 1}
|
|
266
|
-
|
|
267
|
-
return result
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
responder = Responce()
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
import datetime as dt
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Responce(Responder):
|
|
7
|
-
when = {'isMaster': helpers.is_true}
|
|
8
|
-
|
|
9
|
-
result = {
|
|
10
|
-
"ismaster": True,
|
|
11
|
-
"localTime": dt.datetime.now(),
|
|
12
|
-
"logicalSessionTimeoutMinutes": 30,
|
|
13
|
-
"minWireVersion": 0,
|
|
14
|
-
"maxWireVersion": 6,
|
|
15
|
-
"readOnly": False,
|
|
16
|
-
"ok": 1.0
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
responder = Responce()
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
from .is_master import responder as ismaster_responder
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Responce(Responder):
|
|
8
|
-
when = {'ismaster': helpers.is_true}
|
|
9
|
-
|
|
10
|
-
result = ismaster_responder.result
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
responder = Responce()
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import uuid
|
|
2
|
-
|
|
3
|
-
from bson.int64 import Int64
|
|
4
|
-
from mindsdb_sql_parser.ast import Show, Identifier
|
|
5
|
-
|
|
6
|
-
from mindsdb.api.mongo.classes import Responder
|
|
7
|
-
import mindsdb.api.mongo.functions as helpers
|
|
8
|
-
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class Responce(Responder):
|
|
12
|
-
when = {'listCollections': helpers.is_true}
|
|
13
|
-
|
|
14
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
15
|
-
database = request_env['database']
|
|
16
|
-
ast_query = Show(
|
|
17
|
-
category='tables',
|
|
18
|
-
from_table=Identifier(parts=[database])
|
|
19
|
-
)
|
|
20
|
-
data = run_sql_command(request_env, ast_query)
|
|
21
|
-
|
|
22
|
-
tables = []
|
|
23
|
-
for row in data:
|
|
24
|
-
name = list(row.values())[0] # first value
|
|
25
|
-
tables.append({
|
|
26
|
-
'name': name,
|
|
27
|
-
'type': 'collection',
|
|
28
|
-
'options': {},
|
|
29
|
-
'info': {
|
|
30
|
-
'readOnly': False,
|
|
31
|
-
'uuid': uuid.uuid3(uuid.NAMESPACE_DNS, name).bytes,
|
|
32
|
-
},
|
|
33
|
-
'idIndex': {
|
|
34
|
-
'v': 2,
|
|
35
|
-
'key': {
|
|
36
|
-
'_id': 1
|
|
37
|
-
},
|
|
38
|
-
'name': '_id_',
|
|
39
|
-
'ns': f'{database}.{name}'
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
cursor = {
|
|
44
|
-
'id': Int64(0), # should we save id somewhere?
|
|
45
|
-
'ns': f'{database}.$cmd.listCollections',
|
|
46
|
-
'firstBatch': tables
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
'cursor': cursor,
|
|
51
|
-
'ok': 1,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
responder = Responce()
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
from mindsdb_sql_parser.ast import Show
|
|
2
|
-
from mindsdb.api.mongo.classes import Responder
|
|
3
|
-
import mindsdb.api.mongo.functions as helpers
|
|
4
|
-
|
|
5
|
-
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Responce(Responder):
|
|
9
|
-
when = {'listDatabases': helpers.is_true}
|
|
10
|
-
|
|
11
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
12
|
-
|
|
13
|
-
ast_query = Show(category='databases')
|
|
14
|
-
data = run_sql_command(request_env, ast_query)
|
|
15
|
-
|
|
16
|
-
databases = [
|
|
17
|
-
{
|
|
18
|
-
'name': 'admin',
|
|
19
|
-
'sizeOnDisk': 1 << 16,
|
|
20
|
-
'empty': False
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
for row in data:
|
|
25
|
-
databases.append({
|
|
26
|
-
'name': list(row.values())[0], # first value
|
|
27
|
-
'sizeOnDisk': 1 << 16,
|
|
28
|
-
'empty': False
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
'databases': databases,
|
|
33
|
-
'ok': 1,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
responder = Responce()
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'listIndexes': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
9
|
-
return {
|
|
10
|
-
'cursor': [{
|
|
11
|
-
'v': 2,
|
|
12
|
-
'key': {
|
|
13
|
-
'_id': 1
|
|
14
|
-
},
|
|
15
|
-
'name': '_id_',
|
|
16
|
-
'ns': f"{query['$db']}.{query['listIndexes']}"
|
|
17
|
-
}],
|
|
18
|
-
'ok': 1,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
responder = Responce()
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'saslContinue': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
9
|
-
try:
|
|
10
|
-
payload = query['payload'].decode()
|
|
11
|
-
|
|
12
|
-
if len(payload) > 0:
|
|
13
|
-
responce = session.scram.process_client_second_message(payload)
|
|
14
|
-
responce = responce.encode()
|
|
15
|
-
done = False
|
|
16
|
-
else:
|
|
17
|
-
responce = None
|
|
18
|
-
done = True
|
|
19
|
-
|
|
20
|
-
res = {
|
|
21
|
-
'conversationId': 1,
|
|
22
|
-
'done': done,
|
|
23
|
-
'payload': responce,
|
|
24
|
-
'ok': 1
|
|
25
|
-
}
|
|
26
|
-
except Exception as e:
|
|
27
|
-
res = {
|
|
28
|
-
'errmsg': str(e),
|
|
29
|
-
'ok': 0
|
|
30
|
-
}
|
|
31
|
-
return res
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
responder = Responce()
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import mindsdb.api.mongo.functions as helpers
|
|
2
|
-
from mindsdb.api.mongo.classes import Responder
|
|
3
|
-
from mindsdb.utilities import log
|
|
4
|
-
|
|
5
|
-
logger = log.getLogger(__name__)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Responce(Responder):
|
|
9
|
-
when = {"saslStart": helpers.is_true}
|
|
10
|
-
|
|
11
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
12
|
-
try:
|
|
13
|
-
payload = query["payload"].decode()
|
|
14
|
-
mechanism = query.get("mechanism", "SCRAM-SHA-1")
|
|
15
|
-
if mechanism == "SCRAM-SHA-1":
|
|
16
|
-
session.init_scram("sha1")
|
|
17
|
-
elif mechanism == "SCRAM-SHA-256":
|
|
18
|
-
session.init_scram("sha256")
|
|
19
|
-
responce = session.scram.process_client_first_message(payload)
|
|
20
|
-
|
|
21
|
-
res = {
|
|
22
|
-
"conversationId": 1,
|
|
23
|
-
"done": False,
|
|
24
|
-
"payload": responce.encode(),
|
|
25
|
-
"ok": 1,
|
|
26
|
-
}
|
|
27
|
-
except Exception as e:
|
|
28
|
-
logger.warning(str(e))
|
|
29
|
-
res = {"errmsg": str(e), "ok": 0}
|
|
30
|
-
return res
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
responder = Responce()
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'whatsmyuri': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
9
|
-
mongodb_config = mindsdb_env['config']['api']['mongodb']
|
|
10
|
-
host = mongodb_config['host']
|
|
11
|
-
port = mongodb_config['port']
|
|
12
|
-
return {
|
|
13
|
-
'you': f'{host}:{port}',
|
|
14
|
-
'ok': 1
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
responder = Responce()
|