Skip to content

Commit 6a7d0fe

Browse files
Merge pull request #211 from mindsdb/feature/update_database
Added the Update Operation for Databases
2 parents a408514 + 72f4445 commit 6a7d0fe

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

mindsdb_sdk/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = 'mindsdb_sdk'
22
__package_name__ = 'mindsdb_sdk'
3-
__version__ = '3.4.8'
3+
__version__ = '3.4.9'
44
__description__ = "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance"
55
__email__ = "[email protected]"
66
__author__ = 'MindsDB Inc'

mindsdb_sdk/databases.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Dict, List, Union
22

3-
from mindsdb_sql_parser.ast.mindsdb import CreateDatabase
3+
from mindsdb_sql_parser.ast.mindsdb import AlterDatabase, CreateDatabase
44
from mindsdb_sql_parser.ast import DropDatabase, Identifier
55

66
from mindsdb_sdk.utils.objects_collection import CollectionBase
@@ -175,3 +175,19 @@ def get(self, name: str) -> Database:
175175
if name not in databases:
176176
raise AttributeError("Database doesn't exist")
177177
return databases[name]
178+
179+
def update(self, name: str, connection_args: Dict) -> Database:
180+
"""
181+
Update integration connection parameters
182+
183+
:param name: name of integration
184+
:param connection_args: new connection parameters
185+
:return: updated Database object
186+
"""
187+
ast_query = AlterDatabase(
188+
name=Identifier(name),
189+
altered_params={
190+
"parameters": connection_args},
191+
)
192+
self.api.sql_query(ast_query.to_string())
193+
return self.get(name)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
requests
22
pandas >= 1.3.5
3-
mindsdb-sql-parser ~= 0.0.0
3+
mindsdb-sql-parser == 0.10.0
44
docstring-parser >= 0.7.3
55
tenacity >= 8.0.1
66
openai >= 1.74.1

0 commit comments

Comments
 (0)