MindsDB 25.2.4.0__py3-none-any.whl → 25.3.2.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.
Potentially problematic release.
This version of MindsDB might be problematic. Click here for more details.
- mindsdb/__about__.py +1 -1
- mindsdb/__main__.py +16 -1
- mindsdb/api/executor/command_executor.py +1 -1
- mindsdb/api/executor/datahub/datanodes/system_tables.py +6 -1
- mindsdb/api/executor/planner/query_planner.py +6 -2
- mindsdb/api/executor/sql_query/steps/prepare_steps.py +2 -1
- mindsdb/api/executor/sql_query/steps/union_step.py +21 -24
- mindsdb/api/http/gui.py +5 -4
- mindsdb/api/http/initialize.py +19 -19
- mindsdb/api/mongo/classes/query_sql.py +2 -1
- mindsdb/api/mongo/responders/aggregate.py +2 -2
- mindsdb/api/mongo/responders/coll_stats.py +3 -2
- mindsdb/api/mongo/responders/db_stats.py +2 -1
- mindsdb/api/mongo/responders/insert.py +4 -2
- mindsdb/api/mysql/mysql_proxy/classes/fake_mysql_proxy/fake_mysql_proxy.py +2 -1
- mindsdb/api/mysql/mysql_proxy/mysql_proxy.py +5 -4
- mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +2 -4
- mindsdb/integrations/handlers/autosklearn_handler/autosklearn_handler.py +1 -1
- mindsdb/integrations/handlers/gmail_handler/connection_args.py +2 -2
- mindsdb/integrations/handlers/gmail_handler/gmail_handler.py +19 -66
- mindsdb/integrations/handlers/gmail_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/google_calendar_handler/connection_args.py +15 -0
- mindsdb/integrations/handlers/google_calendar_handler/google_calendar_handler.py +31 -41
- mindsdb/integrations/handlers/google_calendar_handler/requirements.txt +0 -2
- mindsdb/integrations/handlers/jira_handler/__init__.py +1 -0
- mindsdb/integrations/handlers/jira_handler/jira_handler.py +22 -80
- mindsdb/integrations/handlers/pgvector_handler/pgvector_handler.py +3 -3
- mindsdb/integrations/handlers/slack_handler/slack_handler.py +2 -1
- mindsdb/integrations/handlers/youtube_handler/youtube_handler.py +2 -38
- mindsdb/integrations/libs/api_handler_generator.py +583 -0
- mindsdb/integrations/libs/llm/utils.py +2 -1
- mindsdb/integrations/utilities/handlers/auth_utilities/google/google_user_oauth_utilities.py +29 -38
- mindsdb/integrations/utilities/pydantic_utils.py +208 -0
- mindsdb/integrations/utilities/rag/pipelines/rag.py +11 -4
- mindsdb/integrations/utilities/rag/retrievers/sql_retriever.py +800 -135
- mindsdb/integrations/utilities/rag/settings.py +390 -152
- mindsdb/integrations/utilities/sql_utils.py +2 -1
- mindsdb/interfaces/agents/agents_controller.py +11 -7
- mindsdb/interfaces/agents/mindsdb_chat_model.py +4 -2
- mindsdb/interfaces/chatbot/chatbot_controller.py +9 -8
- mindsdb/interfaces/database/database.py +2 -1
- mindsdb/interfaces/database/projects.py +28 -2
- mindsdb/interfaces/jobs/jobs_controller.py +4 -1
- mindsdb/interfaces/model/model_controller.py +5 -2
- mindsdb/interfaces/skills/retrieval_tool.py +128 -39
- mindsdb/interfaces/skills/skill_tool.py +7 -7
- mindsdb/interfaces/skills/skills_controller.py +8 -4
- mindsdb/interfaces/storage/db.py +14 -0
- mindsdb/interfaces/storage/json.py +59 -0
- mindsdb/interfaces/storage/model_fs.py +85 -3
- mindsdb/interfaces/triggers/triggers_controller.py +2 -1
- mindsdb/migrations/versions/2022-10-14_43c52d23845a_projects.py +17 -3
- mindsdb/migrations/versions/2025-02-14_4521dafe89ab_added_encrypted_content_to_json_storage.py +29 -0
- mindsdb/migrations/versions/2025-02-19_11347c213b36_added_metadata_to_projects.py +41 -0
- mindsdb/utilities/config.py +6 -2
- mindsdb/utilities/functions.py +11 -0
- {MindsDB-25.2.4.0.dist-info → mindsdb-25.3.2.0.dist-info}/METADATA +219 -222
- {MindsDB-25.2.4.0.dist-info → mindsdb-25.3.2.0.dist-info}/RECORD +61 -60
- {MindsDB-25.2.4.0.dist-info → mindsdb-25.3.2.0.dist-info}/WHEEL +1 -1
- mindsdb/integrations/handlers/gmail_handler/utils.py +0 -45
- mindsdb/integrations/handlers/jira_handler/jira_table.py +0 -172
- mindsdb/integrations/handlers/jira_handler/requirements.txt +0 -1
- {MindsDB-25.2.4.0.dist-info → mindsdb-25.3.2.0.dist-info}/LICENSE +0 -0
- {MindsDB-25.2.4.0.dist-info → mindsdb-25.3.2.0.dist-info}/top_level.txt +0 -0
mindsdb/__about__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
__title__ = 'MindsDB'
|
|
2
2
|
__package_name__ = 'mindsdb'
|
|
3
|
-
__version__ = '25.2.
|
|
3
|
+
__version__ = '25.3.2.0'
|
|
4
4
|
__description__ = "MindsDB's AI SQL Server enables developers to build AI tools that need access to real-time data to perform their tasks"
|
|
5
5
|
__email__ = "jorge@mindsdb.com"
|
|
6
6
|
__author__ = 'MindsDB Inc'
|
mindsdb/__main__.py
CHANGED
|
@@ -9,10 +9,10 @@ import secrets
|
|
|
9
9
|
import traceback
|
|
10
10
|
import threading
|
|
11
11
|
from enum import Enum
|
|
12
|
-
from packaging import version
|
|
13
12
|
from dataclasses import dataclass, field
|
|
14
13
|
from typing import Callable, Optional, Tuple, List
|
|
15
14
|
|
|
15
|
+
from packaging import version
|
|
16
16
|
from sqlalchemy.orm.attributes import flag_modified
|
|
17
17
|
|
|
18
18
|
from mindsdb.utilities import log
|
|
@@ -22,12 +22,14 @@ logger.debug("Starting MindsDB...")
|
|
|
22
22
|
|
|
23
23
|
from mindsdb.__about__ import __version__ as mindsdb_version
|
|
24
24
|
from mindsdb.utilities.config import config
|
|
25
|
+
from mindsdb.utilities.exception import EntityNotExistsError
|
|
25
26
|
from mindsdb.utilities.starters import (
|
|
26
27
|
start_http, start_mysql, start_mongo, start_postgres, start_ml_task_queue, start_scheduler, start_tasks
|
|
27
28
|
)
|
|
28
29
|
from mindsdb.utilities.ps import is_pid_listen_port, get_child_pids
|
|
29
30
|
from mindsdb.utilities.functions import get_versions_where_predictors_become_obsolete
|
|
30
31
|
from mindsdb.interfaces.database.integrations import integration_controller
|
|
32
|
+
from mindsdb.interfaces.database.projects import ProjectController
|
|
31
33
|
import mindsdb.interfaces.storage.db as db
|
|
32
34
|
from mindsdb.integrations.utilities.install import install_dependencies
|
|
33
35
|
from mindsdb.utilities.fs import clean_process_marks, clean_unlinked_process_marks
|
|
@@ -293,6 +295,19 @@ if __name__ == '__main__':
|
|
|
293
295
|
except Exception as e:
|
|
294
296
|
logger.error(f"Error! Something went wrong during DB migrations: {e}")
|
|
295
297
|
|
|
298
|
+
logger.debug(f"Checking if default project {config.get('default_project')} exists")
|
|
299
|
+
project_controller = ProjectController()
|
|
300
|
+
|
|
301
|
+
current_default_project = project_controller.get(is_default=True)
|
|
302
|
+
if current_default_project.record.name != config.get('default_project'):
|
|
303
|
+
try:
|
|
304
|
+
new_default_project = project_controller.get(name=config.get('default_project'))
|
|
305
|
+
log.critical(f"A project with the name '{config.get('default_project')}' already exists")
|
|
306
|
+
sys.exit(1)
|
|
307
|
+
except EntityNotExistsError:
|
|
308
|
+
pass
|
|
309
|
+
project_controller.update(current_default_project.record.id, new_name=config.get('default_project'))
|
|
310
|
+
|
|
296
311
|
apis = os.getenv('MINDSDB_APIS') or config.cmd_args.api
|
|
297
312
|
|
|
298
313
|
if apis is None: # If "--api" option is not specified, start the default APIs
|
|
@@ -1549,7 +1549,7 @@ class ExecuteCommands:
|
|
|
1549
1549
|
elif isinstance(database_name, str) and len(database_name) > 0:
|
|
1550
1550
|
db = database_name
|
|
1551
1551
|
else:
|
|
1552
|
-
db = "
|
|
1552
|
+
db = self.session.config.get("default_project")
|
|
1553
1553
|
table_name = target.parts[-1]
|
|
1554
1554
|
|
|
1555
1555
|
new_where = BinaryOperation(
|
|
@@ -8,6 +8,7 @@ from mindsdb.api.executor.datahub.classes.tables_row import (
|
|
|
8
8
|
TablesRow,
|
|
9
9
|
)
|
|
10
10
|
from mindsdb.utilities import log
|
|
11
|
+
from mindsdb.utilities.config import config
|
|
11
12
|
|
|
12
13
|
logger = log.getLogger(__name__)
|
|
13
14
|
|
|
@@ -292,7 +293,11 @@ class ColumnsTable(Table):
|
|
|
292
293
|
databases, tables_names = _get_scope(query)
|
|
293
294
|
|
|
294
295
|
if databases is None:
|
|
295
|
-
databases = [
|
|
296
|
+
databases = [
|
|
297
|
+
'information_schema',
|
|
298
|
+
config.get('default_project'),
|
|
299
|
+
'files'
|
|
300
|
+
]
|
|
296
301
|
|
|
297
302
|
for db_name in databases:
|
|
298
303
|
tables = {}
|
|
@@ -25,6 +25,10 @@ from mindsdb.api.executor.planner.utils import (
|
|
|
25
25
|
)
|
|
26
26
|
from mindsdb.api.executor.planner.plan_join import PlanJoin
|
|
27
27
|
from mindsdb.api.executor.planner.query_prepare import PreparedStatementPlanner
|
|
28
|
+
from mindsdb.utilities.config import config
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
default_project = config.get('default_project')
|
|
28
32
|
|
|
29
33
|
|
|
30
34
|
class QueryPlanner:
|
|
@@ -54,12 +58,12 @@ class QueryPlanner:
|
|
|
54
58
|
self.integrations[integration_name] = integration
|
|
55
59
|
|
|
56
60
|
# allow to select from mindsdb namespace
|
|
57
|
-
_projects.add(
|
|
61
|
+
_projects.add(default_project)
|
|
58
62
|
|
|
59
63
|
self.default_namespace = default_namespace
|
|
60
64
|
|
|
61
65
|
# legacy parameter
|
|
62
|
-
self.predictor_namespace = predictor_namespace.lower() if predictor_namespace else
|
|
66
|
+
self.predictor_namespace = predictor_namespace.lower() if predictor_namespace else default_project
|
|
63
67
|
|
|
64
68
|
# map for lower names of predictors
|
|
65
69
|
|
|
@@ -10,6 +10,7 @@ from mindsdb.api.executor.planner.steps import (
|
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
from mindsdb.api.executor.sql_query.result_set import ResultSet, Column
|
|
13
|
+
from mindsdb.utilities.config import config
|
|
13
14
|
|
|
14
15
|
from .base import BaseStepCall
|
|
15
16
|
|
|
@@ -20,7 +21,7 @@ class GetPredictorColumnsCall(BaseStepCall):
|
|
|
20
21
|
|
|
21
22
|
def call(self, step):
|
|
22
23
|
|
|
23
|
-
mindsdb_database_name = '
|
|
24
|
+
mindsdb_database_name = config.get('default_project')
|
|
24
25
|
|
|
25
26
|
predictor_name = step.predictor.parts[-1]
|
|
26
27
|
dn = self.session.datahub.get(mindsdb_database_name)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import hashlib
|
|
2
|
-
|
|
3
1
|
from mindsdb.api.executor.planner.steps import UnionStep
|
|
4
2
|
|
|
5
3
|
from mindsdb.api.executor.sql_query.result_set import ResultSet
|
|
6
4
|
from mindsdb.api.executor.exceptions import WrongArgumentError
|
|
5
|
+
from mindsdb.api.executor.utilities.sql import query_df_with_type_infer_fallback
|
|
6
|
+
import numpy as np
|
|
7
7
|
|
|
8
8
|
from .base import BaseStepCall
|
|
9
9
|
|
|
@@ -30,27 +30,24 @@ class UnionStepCall(BaseStepCall):
|
|
|
30
30
|
# if type1 != type2:
|
|
31
31
|
# raise ErSqlWrongArguments(f'UNION types mismatch: {type1} != {type2}')
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
records_hashes.append(checksum)
|
|
53
|
-
results.append(list(row))
|
|
54
|
-
data.add_raw_values(results)
|
|
33
|
+
table_a, names = left_result.to_df_cols()
|
|
34
|
+
table_b, _ = right_result.to_df_cols()
|
|
35
|
+
|
|
36
|
+
op = 'UNION ALL'
|
|
37
|
+
if step.unique:
|
|
38
|
+
op = 'UNION'
|
|
39
|
+
query = f"""
|
|
40
|
+
SELECT * FROM table_a
|
|
41
|
+
{op}
|
|
42
|
+
SELECT * FROM table_b
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
resp_df, _description = query_df_with_type_infer_fallback(query, {
|
|
46
|
+
'table_a': table_a,
|
|
47
|
+
'table_b': table_b
|
|
48
|
+
})
|
|
49
|
+
resp_df.replace({np.nan: None}, inplace=True)
|
|
50
|
+
|
|
51
|
+
data = ResultSet().from_df_cols(resp_df, col_names=names)
|
|
55
52
|
|
|
56
53
|
return data
|
mindsdb/api/http/gui.py
CHANGED
|
@@ -5,6 +5,7 @@ from pathlib import Path
|
|
|
5
5
|
from zipfile import ZipFile
|
|
6
6
|
|
|
7
7
|
import requests
|
|
8
|
+
from packaging.version import Version
|
|
8
9
|
|
|
9
10
|
from mindsdb.utilities.config import Config
|
|
10
11
|
from mindsdb.utilities import log
|
|
@@ -65,7 +66,7 @@ def download_gui(destignation, version):
|
|
|
65
66
|
"""
|
|
66
67
|
|
|
67
68
|
|
|
68
|
-
def update_static(
|
|
69
|
+
def update_static(gui_version: Version):
|
|
69
70
|
"""Update Scout files basing on compatible-config.json content.
|
|
70
71
|
Files will be downloaded and updated if new version of GUI > current.
|
|
71
72
|
Current GUI version stored in static/version.txt.
|
|
@@ -74,11 +75,11 @@ def update_static(gui_version_lv):
|
|
|
74
75
|
static_path = Path(config["paths"]["static"])
|
|
75
76
|
|
|
76
77
|
logger.info(
|
|
77
|
-
f"New version of GUI available ({
|
|
78
|
+
f"New version of GUI available ({gui_version.base_version}). Downloading..."
|
|
78
79
|
)
|
|
79
80
|
|
|
80
81
|
temp_dir = tempfile.mkdtemp(prefix="mindsdb_gui_files_")
|
|
81
|
-
success = download_gui(temp_dir,
|
|
82
|
+
success = download_gui(temp_dir, gui_version.base_version)
|
|
82
83
|
if success is False:
|
|
83
84
|
shutil.rmtree(temp_dir)
|
|
84
85
|
return False
|
|
@@ -90,5 +91,5 @@ def update_static(gui_version_lv):
|
|
|
90
91
|
shutil.copytree(temp_dir, str(static_path))
|
|
91
92
|
shutil.rmtree(temp_dir_for_rm)
|
|
92
93
|
|
|
93
|
-
logger.info(f"GUI version updated to {
|
|
94
|
+
logger.info(f"GUI version updated to {gui_version.base_version}")
|
|
94
95
|
return True
|
mindsdb/api/http/initialize.py
CHANGED
|
@@ -6,7 +6,6 @@ import traceback
|
|
|
6
6
|
import webbrowser
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
from http import HTTPStatus
|
|
9
|
-
from distutils.version import LooseVersion
|
|
10
9
|
|
|
11
10
|
import requests
|
|
12
11
|
from flask import Flask, url_for, make_response, request, send_from_directory
|
|
@@ -14,6 +13,7 @@ from flask.json import dumps
|
|
|
14
13
|
from flask_compress import Compress
|
|
15
14
|
from flask_restx import Api
|
|
16
15
|
from werkzeug.exceptions import HTTPException
|
|
16
|
+
from packaging.version import Version, parse as parse_version
|
|
17
17
|
|
|
18
18
|
from mindsdb.__about__ import __version__ as mindsdb_version
|
|
19
19
|
from mindsdb.api.http.gui import update_static
|
|
@@ -72,7 +72,7 @@ def custom_output_json(data, code, headers=None):
|
|
|
72
72
|
return resp
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
def get_last_compatible_gui_version() ->
|
|
75
|
+
def get_last_compatible_gui_version() -> Version:
|
|
76
76
|
logger.debug("Getting last compatible frontend..")
|
|
77
77
|
try:
|
|
78
78
|
res = requests.get('https://mindsdb-web-builds.s3.amazonaws.com/compatible-config.json', timeout=5)
|
|
@@ -95,7 +95,7 @@ def get_last_compatible_gui_version() -> LooseVersion:
|
|
|
95
95
|
logger.error(f"Cant decode compatible-config.json: {e}")
|
|
96
96
|
return False
|
|
97
97
|
|
|
98
|
-
current_mindsdb_lv =
|
|
98
|
+
current_mindsdb_lv = parse_version(mindsdb_version)
|
|
99
99
|
|
|
100
100
|
try:
|
|
101
101
|
gui_versions = {}
|
|
@@ -103,31 +103,31 @@ def get_last_compatible_gui_version() -> LooseVersion:
|
|
|
103
103
|
max_gui_lv = None
|
|
104
104
|
for el in versions['mindsdb']:
|
|
105
105
|
if el['mindsdb_version'] is None:
|
|
106
|
-
gui_lv =
|
|
106
|
+
gui_lv = parse_version(el['gui_version'])
|
|
107
107
|
else:
|
|
108
|
-
mindsdb_lv =
|
|
109
|
-
gui_lv =
|
|
110
|
-
if mindsdb_lv.
|
|
111
|
-
gui_versions[mindsdb_lv.
|
|
108
|
+
mindsdb_lv = parse_version(el['mindsdb_version'])
|
|
109
|
+
gui_lv = parse_version(el['gui_version'])
|
|
110
|
+
if mindsdb_lv.base_version not in gui_versions or gui_lv > gui_versions[mindsdb_lv.base_version]:
|
|
111
|
+
gui_versions[mindsdb_lv.base_version] = gui_lv
|
|
112
112
|
if max_mindsdb_lv is None or max_mindsdb_lv < mindsdb_lv:
|
|
113
113
|
max_mindsdb_lv = mindsdb_lv
|
|
114
114
|
if max_gui_lv is None or max_gui_lv < gui_lv:
|
|
115
115
|
max_gui_lv = gui_lv
|
|
116
116
|
|
|
117
|
-
all_mindsdb_lv = [
|
|
117
|
+
all_mindsdb_lv = [parse_version(x) for x in gui_versions.keys()]
|
|
118
118
|
all_mindsdb_lv.sort()
|
|
119
119
|
|
|
120
|
-
if current_mindsdb_lv.
|
|
121
|
-
gui_version_lv = gui_versions[current_mindsdb_lv.
|
|
120
|
+
if current_mindsdb_lv.base_version in gui_versions:
|
|
121
|
+
gui_version_lv = gui_versions[current_mindsdb_lv.base_version]
|
|
122
122
|
elif current_mindsdb_lv > all_mindsdb_lv[-1]:
|
|
123
123
|
gui_version_lv = max_gui_lv
|
|
124
124
|
else:
|
|
125
|
-
lower_versions = {key: value for key, value in gui_versions.items() if
|
|
125
|
+
lower_versions = {key: value for key, value in gui_versions.items() if parse_version(key) < current_mindsdb_lv}
|
|
126
126
|
if len(lower_versions) == 0:
|
|
127
|
-
gui_version_lv = gui_versions[all_mindsdb_lv[0].
|
|
127
|
+
gui_version_lv = gui_versions[all_mindsdb_lv[0].base_version]
|
|
128
128
|
else:
|
|
129
|
-
all_lower_versions = [
|
|
130
|
-
gui_version_lv = gui_versions[all_lower_versions[-1].
|
|
129
|
+
all_lower_versions = [parse_version(x) for x in lower_versions.keys()]
|
|
130
|
+
gui_version_lv = gui_versions[all_lower_versions[-1].base_version]
|
|
131
131
|
except Exception as e:
|
|
132
132
|
logger.error(f"Error in compatible-config.json structure: {e}")
|
|
133
133
|
return False
|
|
@@ -136,7 +136,7 @@ def get_last_compatible_gui_version() -> LooseVersion:
|
|
|
136
136
|
return gui_version_lv
|
|
137
137
|
|
|
138
138
|
|
|
139
|
-
def get_current_gui_version() ->
|
|
139
|
+
def get_current_gui_version() -> Version:
|
|
140
140
|
logger.debug("Getting current frontend version..")
|
|
141
141
|
config = Config()
|
|
142
142
|
static_path = Path(config['paths']['static'])
|
|
@@ -148,7 +148,7 @@ def get_current_gui_version() -> LooseVersion:
|
|
|
148
148
|
current_gui_version = f.readline()
|
|
149
149
|
|
|
150
150
|
current_gui_lv = (
|
|
151
|
-
None if current_gui_version is None else
|
|
151
|
+
None if current_gui_version is None else parse_version(current_gui_version)
|
|
152
152
|
)
|
|
153
153
|
logger.debug(f"Current frontend version: {current_gui_lv}.")
|
|
154
154
|
|
|
@@ -163,7 +163,7 @@ def initialize_static():
|
|
|
163
163
|
required_gui_version = config['gui'].get('version')
|
|
164
164
|
|
|
165
165
|
if required_gui_version is not None:
|
|
166
|
-
required_gui_version_lv =
|
|
166
|
+
required_gui_version_lv = parse_version(required_gui_version)
|
|
167
167
|
success = True
|
|
168
168
|
if (
|
|
169
169
|
current_gui_version_lv is None
|
|
@@ -176,7 +176,7 @@ def initialize_static():
|
|
|
176
176
|
return False
|
|
177
177
|
|
|
178
178
|
# ignore versions like '23.9.2.2'
|
|
179
|
-
if current_gui_version_lv is not None and len(current_gui_version_lv.
|
|
179
|
+
if current_gui_version_lv is not None and len(current_gui_version_lv.release) < 3:
|
|
180
180
|
if current_gui_version_lv == last_gui_version_lv:
|
|
181
181
|
return True
|
|
182
182
|
logger.debug("Updating gui..")
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from mindsdb.api.executor.controllers import SessionController
|
|
2
2
|
from mindsdb.api.executor.command_executor import ExecuteCommands
|
|
3
|
+
from mindsdb.utilities.config import config
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def run_sql_command(request_env, ast_query):
|
|
6
7
|
sql_session = SessionController()
|
|
7
|
-
sql_session.database = request_env.get('database', '
|
|
8
|
+
sql_session.database = request_env.get('database', config.get('default_project'))
|
|
8
9
|
|
|
9
10
|
command_executor = ExecuteCommands(sql_session)
|
|
10
11
|
ret = command_executor.execute_command(ast_query)
|
|
@@ -5,8 +5,8 @@ from mindsdb_sql_parser.ast import Identifier, Insert, CreateTable
|
|
|
5
5
|
from mindsdb.api.mongo.classes import Responder
|
|
6
6
|
import mindsdb.api.mongo.functions as helpers
|
|
7
7
|
from mindsdb.api.mongo.responders.find import find_to_ast
|
|
8
|
-
|
|
9
8
|
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
9
|
+
from mindsdb.utilities.config import config
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def aggregate_to_ast(query, database):
|
|
@@ -63,7 +63,7 @@ class Responce(Responder):
|
|
|
63
63
|
|
|
64
64
|
first_step = query['pipeline'][0]
|
|
65
65
|
if '$match' in first_step:
|
|
66
|
-
ast_query = aggregate_to_ast(query, request_env.get('database', '
|
|
66
|
+
ast_query = aggregate_to_ast(query, request_env.get('database', config.get('default_project')))
|
|
67
67
|
|
|
68
68
|
data = run_sql_command(request_env, ast_query)
|
|
69
69
|
|
|
@@ -3,6 +3,7 @@ from mindsdb_sql_parser.ast import Describe, Identifier
|
|
|
3
3
|
from mindsdb.api.mongo.classes import Responder
|
|
4
4
|
import mindsdb.api.mongo.functions as helpers
|
|
5
5
|
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
6
|
+
from mindsdb.utilities.config import config
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class Responce(Responder):
|
|
@@ -14,7 +15,7 @@ class Responce(Responder):
|
|
|
14
15
|
|
|
15
16
|
scale = query.get('scale')
|
|
16
17
|
|
|
17
|
-
if db != '
|
|
18
|
+
if db != config.get('default_project') or collection == 'predictors' or scale is None:
|
|
18
19
|
# old behavior
|
|
19
20
|
# NOTE real answer is huge, i removed most data from it.
|
|
20
21
|
res = {
|
|
@@ -37,7 +38,7 @@ class Responce(Responder):
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
res['ns'] = f"{db}.{collection}"
|
|
40
|
-
if db == '
|
|
41
|
+
if db == config.get('default_project') and collection == 'predictors':
|
|
41
42
|
res['count'] = len(mindsdb_env['model_controller'].get_models())
|
|
42
43
|
else:
|
|
43
44
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from mindsdb.api.mongo.classes import Responder
|
|
2
2
|
import mindsdb.api.mongo.functions as helpers
|
|
3
|
+
from mindsdb.utilities.config import config
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
class Responce(Responder):
|
|
@@ -8,7 +9,7 @@ class Responce(Responder):
|
|
|
8
9
|
def result(self, query, request_env, mindsdb_env, session):
|
|
9
10
|
db = query['$db']
|
|
10
11
|
collections = 0
|
|
11
|
-
if db == '
|
|
12
|
+
if db == config.get('default_project'):
|
|
12
13
|
collections = 2 + len(mindsdb_env['model_controller'].get_models())
|
|
13
14
|
return {
|
|
14
15
|
'db': db,
|
|
@@ -16,8 +16,10 @@ from mindsdb.api.mongo.responders.find import find_to_ast
|
|
|
16
16
|
from mindsdb.api.mongo.utilities.mongodb_parser import MongodbParser
|
|
17
17
|
from mindsdb.integrations.libs.response import HandlerStatusResponse
|
|
18
18
|
from mindsdb.utilities import log
|
|
19
|
+
from mindsdb.utilities.config import config
|
|
19
20
|
|
|
20
21
|
logger = log.getLogger(__name__)
|
|
22
|
+
default_project = config.get("default_project")
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
class Responce(Responder):
|
|
@@ -186,7 +188,7 @@ class Responce(Responder):
|
|
|
186
188
|
query["sort"] = step["args"][0]
|
|
187
189
|
# TODO implement group modifiers
|
|
188
190
|
ast_query = find_to_ast(
|
|
189
|
-
query, request_env.get("database",
|
|
191
|
+
query, request_env.get("database", default_project)
|
|
190
192
|
)
|
|
191
193
|
|
|
192
194
|
# to string
|
|
@@ -197,7 +199,7 @@ class Responce(Responder):
|
|
|
197
199
|
"pipeline": mql.pipeline[0]["args"][0],
|
|
198
200
|
}
|
|
199
201
|
ast_query = aggregate_to_ast(
|
|
200
|
-
query, request_env.get("database",
|
|
202
|
+
query, request_env.get("database", default_project)
|
|
201
203
|
)
|
|
202
204
|
query_str = ast_query.to_string()
|
|
203
205
|
except Exception:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from mindsdb.api.executor.controllers import SessionController
|
|
2
2
|
from mindsdb.api.mysql.mysql_proxy.libs.constants.mysql import CHARSET_NUMBERS
|
|
3
3
|
from mindsdb.api.mysql.mysql_proxy.mysql_proxy import MysqlProxy
|
|
4
|
+
from mindsdb.utilities.config import config
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
def empty_fn():
|
|
@@ -29,7 +30,7 @@ class FakeMysqlProxy(MysqlProxy):
|
|
|
29
30
|
self.connection_id = None
|
|
30
31
|
|
|
31
32
|
self.session = SessionController()
|
|
32
|
-
self.session.database = '
|
|
33
|
+
self.session.database = config.get('default_project')
|
|
33
34
|
|
|
34
35
|
def is_cloud_connection(self):
|
|
35
36
|
return {
|
|
@@ -81,7 +81,7 @@ from mindsdb.api.executor import exceptions as exec_exc
|
|
|
81
81
|
from mindsdb.api.common.check_auth import check_auth
|
|
82
82
|
from mindsdb.api.mysql.mysql_proxy.utilities.lightwood_dtype import dtype
|
|
83
83
|
from mindsdb.utilities import log
|
|
84
|
-
from mindsdb.utilities.config import
|
|
84
|
+
from mindsdb.utilities.config import config
|
|
85
85
|
from mindsdb.utilities.context import context as ctx
|
|
86
86
|
from mindsdb.utilities.otel.metric_handlers import get_query_request_counter
|
|
87
87
|
from mindsdb.utilities.wizards import make_ssl_cert
|
|
@@ -448,7 +448,6 @@ class MysqlProxy(SocketServer.BaseRequestHandler):
|
|
|
448
448
|
connection. '0000' selected because in real mysql connection it should be lenght of package,
|
|
449
449
|
and it can not be 0.
|
|
450
450
|
"""
|
|
451
|
-
config = Config()
|
|
452
451
|
is_cloud = config.get("cloud", False)
|
|
453
452
|
|
|
454
453
|
if sys.platform != "linux" or is_cloud is False:
|
|
@@ -746,7 +745,7 @@ class MysqlProxy(SocketServer.BaseRequestHandler):
|
|
|
746
745
|
sql = SqlStatementParser.clear_sql(sql)
|
|
747
746
|
logger.debug(f'Incoming query: {sql}')
|
|
748
747
|
profiler.set_meta(
|
|
749
|
-
query=sql, api="mysql", environment=
|
|
748
|
+
query=sql, api="mysql", environment=config.get("environment")
|
|
750
749
|
)
|
|
751
750
|
with profiler.Context("mysql_query_processing"):
|
|
752
751
|
response = self.process_query(sql)
|
|
@@ -877,6 +876,9 @@ class MysqlProxy(SocketServer.BaseRequestHandler):
|
|
|
877
876
|
def set_context(self, context):
|
|
878
877
|
if "db" in context:
|
|
879
878
|
self.session.database = context["db"]
|
|
879
|
+
else:
|
|
880
|
+
self.session.database = config.get('default_project')
|
|
881
|
+
|
|
880
882
|
if "profiling" in context:
|
|
881
883
|
self.session.profiling = context["profiling"]
|
|
882
884
|
if "predictor_cache" in context:
|
|
@@ -903,7 +905,6 @@ class MysqlProxy(SocketServer.BaseRequestHandler):
|
|
|
903
905
|
Create a server and wait for incoming connections until Ctrl-C
|
|
904
906
|
"""
|
|
905
907
|
global logger
|
|
906
|
-
config = Config()
|
|
907
908
|
|
|
908
909
|
cert_path = config["api"]["mysql"].get("certificate_path")
|
|
909
910
|
if cert_path is None or cert_path == "":
|
|
@@ -26,7 +26,7 @@ from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_message impor
|
|
|
26
26
|
from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_packets import PostgresPacketReader, \
|
|
27
27
|
PostgresPacketBuilder
|
|
28
28
|
from mindsdb.api.postgres.postgres_proxy.utilities import strip_null_byte
|
|
29
|
-
from mindsdb.utilities.config import
|
|
29
|
+
from mindsdb.utilities.config import config
|
|
30
30
|
from mindsdb.utilities.context import context as ctx
|
|
31
31
|
from mindsdb.utilities import log
|
|
32
32
|
from mindsdb.api.mysql.mysql_proxy.external_libs.mysql_scramble import scramble as scramble_func
|
|
@@ -92,7 +92,6 @@ class PostgresProxyHandler(socketserver.StreamRequestHandler):
|
|
|
92
92
|
Copied from mysql_proxy
|
|
93
93
|
TODO: Extract method into common
|
|
94
94
|
"""
|
|
95
|
-
config = Config()
|
|
96
95
|
is_cloud = config.get('cloud', False)
|
|
97
96
|
|
|
98
97
|
if sys.platform != 'linux' or is_cloud is False:
|
|
@@ -237,7 +236,7 @@ class PostgresProxyHandler(socketserver.StreamRequestHandler):
|
|
|
237
236
|
self.server.connection_id += 1
|
|
238
237
|
self.connection_id = self.server.connection_id
|
|
239
238
|
self.session = SessionController()
|
|
240
|
-
self.session.database = '
|
|
239
|
+
self.session.database = config.get('default_project')
|
|
241
240
|
|
|
242
241
|
if hasattr(self.server, 'salt') and isinstance(self.server.salt, str):
|
|
243
242
|
self.salt = self.server.salt
|
|
@@ -461,7 +460,6 @@ class PostgresProxyHandler(socketserver.StreamRequestHandler):
|
|
|
461
460
|
|
|
462
461
|
@staticmethod
|
|
463
462
|
def startProxy():
|
|
464
|
-
config = Config()
|
|
465
463
|
host = config['api']['postgres']['host']
|
|
466
464
|
port = int(config['api']['postgres']['port'])
|
|
467
465
|
server = TcpServer((host, port), PostgresProxyHandler)
|