-
Notifications
You must be signed in to change notification settings - Fork 754
Description
Describe the bug
Whenever I try to connect to an azure sql DB with Ibis, it throws an exception and the datasource shows empty. The connection itself does work when querying my database, its just the introspection piece that is failing. Looking in the ibis code, get_databases method wraps the call to self._connection.list_catalogs(). When I ran that method on my ibis connection it returned "mydb" and "master". So I believe the problem is when it then iterates and introspects each db because introspecting master is not supported in azure sql.
Here is the stacktrace:
--- Logging error ---
Traceback (most recent call last):
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_sql\get_engines.py", line 89, in engine_to_data_source_connection
databases = engine.get_databases(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_sql\engines\ibis.py", line 170, in get_databases
schemas = self._get_schemas(
^^^^^^^^^^^^^^^^^^
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_sql\engines\ibis.py", line 207, in _get_schemas
schema_names = self.connection.list_databases(catalog=database)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\ibis\backends\mssql_init.py", line 593, in list_databases
with self.safe_raw_sql(query) as cur:
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\contextlib.py", line 137, in enter
return next(self.gen)
^^^^^^^^^^^^^^
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\ibis\backends\mssql_init.py", line 428, in _safe_raw_sql
cur.execute(query, *args, **kwargs)
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Reference to database and/or server name in 'master.INFORMATION_SCHEMA.SCHEMATA' is not supported in this version of SQL Server. (40515) (SQLExecDirectW)")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\logging_init_.py", line 1163, in emit
stream.write(msg + self.terminator)
OSError: [WinError 1] Incorrect function
Call stack:
File "", line 1, in
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\multiprocessing\spawn.py", line 122, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\multiprocessing\spawn.py", line 135, in _main
return self._bootstrap(parent_sentinel)
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\multiprocessing\process.py", line 314, in _bootstrap
self.run()
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 3071, in launch_kernel
asyncio.run(control_loop(kernel))
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\asyncio\base_events.py", line 651, in run_until_complete
self.run_forever()
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\asyncio\base_events.py", line 618, in run_forever
self._run_once()
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\asyncio\base_events.py", line 1951, in _run_once
handle._run()
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\asyncio\events.py", line 84, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 3065, in control_loop
await kernel.handle_message(request)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 2257, in handle_message
await self.request_handler.handle(request)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 2878, in handle
return await handler(request)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 2139, in handle_execute_multiple
await self.run(request.execution_requests)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 1563, in run
await _run_with_uninstantiated_requests(execution_requests)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 1503, in _run_with_uninstantiated_requests
await self._run_cells(
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 1357, in _run_cells
while cell_ids := await self._run_cells_internal(cell_ids):
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runtime.py", line 1442, in _run_cells_internal
await runner.run_all()
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runner\cell_runner.py", line 692, in run_all
post_hook(cell, self, run_result)
File "C:\Users\jsarver\AppData\Roaming\uv\python\cpython-3.12.0-windows-x86_64-none\Lib\contextlib.py", line 81, in inner
return func(*args, **kwds)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_runtime\runner\hooks_post_execution.py", line 173, in _broadcast_data_source_connection
engine_to_data_source_connection(variable, engine)
File "C:\Users\jsarver\Code\marimo_testing.venv\Lib\site-packages\marimo_sql\get_engines.py", line 101, in engine_to_data_source_connection
LOGGER.warning(f"Failed to introspect datasource: {e}")
Message: 'Failed to introspect datasource: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Reference to database and/or server name in 'master.INFORMATION_SCHEMA.SCHEMATA' is not supported in this version of SQL Server. (40515) (SQLExecDirectW)")'
Argument
Will you submit a PR?
- Yes
Environment
{
"marimo": "0.16.5",
"editable": false,
"location": "C:/Users/jsarver/Code/marimo_testing/.venv/Lib/site-packages/marimo",
"OS": "Windows",
"OS Version": "11",
"Processor": "AMD64 Family 23 Model 24 Stepping 1, AuthenticAMD",
"Python Version": "3.12.0",
"Locale": "en_US",
"Binaries": {
"Browser": "141.0.7390.55",
"Node": "v20.9.0"
},
"Dependencies": {
"click": "8.3.0",
"docutils": "0.22.2",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.9",
"narwhals": "2.8.0",
"packaging": "25.0",
"psutil": "7.1.0",
"pygments": "2.19.2",
"pymdown-extensions": "10.16.1",
"pyyaml": "6.0.3",
"starlette": "0.48.0",
"tomlkit": "0.13.3",
"typing-extensions": "4.15.0",
"uvicorn": "0.35.0",
"websockets": "15.0.1"
},
"Optional Dependencies": {
"altair": "5.5.0",
"duckdb": "1.4.1",
"ibis-framework": "11.0.0",
"openai": "2.3.0",
"pandas": "2.3.3",
"polars": "1.34.0",
"pyarrow": "21.0.0",
"loro": "1.8.1",
"pytest": "8.4.2",
"ruff": "0.14.0",
"sqlglot": "27.27.0"
},
"Experimental Flags": {
"rtc_v2": false
}
}
Code to reproduce
import marimo
__generated_with = "0.16.5"
app = marimo.App(width="medium")
@app.cell
def _():
from marimo_tools.engines import get_engine
d = get_engine('dev')
return
@app.cell
def _(u):
import ibis
con = ibis.mssql.connect(
host=u.host, database=u.database, user=u.username, password=u.password,
driver="ODBC Driver 17 for SQL Server"
)
return
if name == "main":
app.run()