added motherduck support in duckDB#10385
Conversation
|
@parthiv11 |
|
Okay
…On Thu, Jun 26, 2025, 6:58 PM martyna-mindsdb ***@***.***> wrote:
*martyna-mindsdb* left a comment (mindsdb/minds-platform#10385)
<#10385 (comment)>
@parthiv11 <https://github.com/parthiv11>
Please resolve the conflicts so we can merge this.
—
Reply to this email directly, view it on GitHub
<#10385 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASBGDTDB7RALBGYSOFK7RQD3FPYRVAVCNFSM6AAAAABVPZTZH6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMBYGUYDGOBXGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
done @martyna-mindsdb |
|
@parthiv11 |
|
@hamishfagg |
Co-authored-by: andrew <elkin.andr@gmail.com>
Co-authored-by: martyna-mindsdb <109554435+martyna-mindsdb@users.noreply.github.com>
# Conflicts: # docs/setup/environment-vars.mdx # mindsdb/integrations/handlers/hubspot_handler/hubspot_tables.py
| self.connect() | ||
| response.success = True | ||
| except Exception as e: | ||
| logger.error( | ||
| f'Error connecting to DuckDB {self.connection_data["database"]}, {e}!' | ||
| ) | ||
| logger.error(f"Error connecting to DuckDB {self.connection_data['database']}, {e}!") | ||
| response.error_message = str(e) | ||
| finally: | ||
| if response.success is True and need_to_close: |
There was a problem hiding this comment.
Duplicate Code:
This function check_connection duplicates existing code.
📍 Original Location:
mindsdb/integrations/handlers/databend_handler/databend_handler.py:85-107
Function: check_connection
💡 Recommendation:
Implement a default check_connection() on the DatabaseHandler base class that follows this exact try/except/finally template, calling the subclass's connect(). Subclasses that need extra checks (e.g., SQLiteHandler's file existence guard) can override or call super().check_connection() and add pre-conditions. This would eliminate the boilerplate from every SQL handler.
Consider importing and reusing the existing function instead of duplicating the logic.
| Response: Details of the table. | ||
| """ | ||
|
|
||
| query = f'DESCRIBE {table_name};' | ||
| return self.native_query(query) | ||
| query = f"DESCRIBE {table_name};" |
There was a problem hiding this comment.
Duplicate Code:
This function get_columns duplicates existing code.
📍 Original Location:
mindsdb/integrations/handlers/clickhouse_handler/clickhouse_handler.py:161-167
Function: get_columns
💡 Recommendation:
Consider a base-class or mixin get_columns() that issues a configurable describe query (e.g., a per-dialect template). For DuckDB and ClickHouse, the template is DESCRIBE {table_name}. Handlers that need extra column renaming (e.g., DatabendHandler renames Field→column_name) can override with a super() call followed by a rename step.
Consider importing and reusing the existing function instead of duplicating the logic.
|
@parthiv11, can you solve static code checks errors? Can you see a content of this error? |
…nd connection_args
|
done @ea-rus |
| motherduck_token = self.connection_data.get("motherduck_token") | ||
| if motherduck_token: | ||
| database = ( | ||
| f"md:{self.connection_data.get('database')}?motherduck_token={motherduck_token}&attach_mode=single" |
There was a problem hiding this comment.
Correctness: The motherduck_token is embedded directly in the database connection string as a URL query parameter (?motherduck_token=...), which means it will appear in plaintext in logs, error messages (e.g., the check_connection error log includes the database string), and any tracing/debugging output. This leaks a sensitive credential.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In mindsdb/integrations/handlers/duckdb_handler/duckdb_handler.py, lines 47-50, the motherduck_token is embedded in the database connection string URL. This causes the token to appear in log output (e.g., check_connection logs `self.connection_data['database']` on error, and native_query logs it too). Consider passing the token via the duckdb `config` parameter (e.g., `duckdb.connect(database='md:dbname', config={'motherduck_token': token})`) instead of embedding it in the URL, to avoid credential exposure in logs and error messages.
Description
Please include a summary of the change and the issue it solves.
Fixes #10378
Type of change
(Please delete options that are not relevant)
Verification Process
To ensure the changes are working as expected:
Additional Media:
Checklist: