Unable to load LOB data
Describe the bug
Hello guys,
Hope you're doing fine.
Thanks for this amazing tool.
I developed a tool using python-oracledb where I designed functions to extract data. While executing query to analyse data, I found an issue on marimo notebook where I read a field LOB data and for any reason marimo drops the connection.
According to my research the issue occurs when attempting to access or format an Oracle LOB (e.g., CLOB or BLOB) using the oracledb package, an InterfaceError: DPY-1001: not connected to database is raised. This also occurs even though the query execution completes successfully — the error arises when trying to access or format the LOB afterward.
I did the same troubeshooting with Jupyter Notebook and it performs as expected.
Jupyter Notebook
Marimo Notebook
Will you submit a PR?
- [ ] Yes
Environment
{ "marimo": "0.13.15", "OS": "Windows", "OS Version": "11", "Processor": "Intel64 Family 6 Model 142 Stepping 12, GenuineIntel", "Python Version": "3.13.2", "Binaries": { "Browser": "137.0.7151.103", "Node": "v23.6.0" }, "Dependencies": { "click": "8.1.8", "docutils": "0.21.2", "itsdangerous": "2.2.0", "jedi": "0.19.2", "markdown": "3.7", "narwhals": "1.32.0", "packaging": "24.2", "psutil": "7.0.0", "pygments": "2.19.1", "pymdown-extensions": "10.14.3", "pyyaml": "6.0.2", "starlette": "0.46.1", "tomlkit": "0.13.2", "typing-extensions": "4.13.0", "uvicorn": "0.34.0", "websockets": "15.0.1" }, "Optional Dependencies": { "altair": "5.5.0", "duckdb": "1.2.1", "nbformat": "5.10.4", "openai": "1.69.0", "pandas": "2.2.3", "polars": "1.26.0", "pyarrow": "19.0.1", "loro": "1.5.1", "python-lsp-ruff": "2.2.2", "ruff": "0.11.2", "sqlglot": "26.12.0" }, "Experimental Flags": {} }
Code to reproduce
conn = oracledb.connect(user="user", password="pass", dsn="dsn_string")
cursor = conn.cursor()
cursor.execute("SELECT clob_col FROM my_table WHERE id = :id", id=1)
clob = cursor.fetchone()[0]
# At this point, if the connection is closed or if the object is passed to a formatter, the following error occurs:
print(clob) # or str(clob)
InterfaceError: DPY-1001: not connected to database
hmm, does the following work:
with oracledb.connect(user=un, password=pw, dsn=cs) as connection:
with connection.cursor() as cursor:
sql = "select sysdate from dual"
for r in cursor.execute(sql):
print(r)
I took this from the docs, hence it may be that the connection is closing prematurely.
@Light2Dark I did what you suggest and found that the code above doesn't return an error because it print the clob as text and not the value of the clob.
Guess jupiter was doing this all the time. Since the result of clod is a locator, when add into dict and display, marimo tries to access the locator value. Since the connection is close because of context manager raise an exception.
As a fix, I had to change to oracledb.defaults.fetch_lobs = False and according to the official documentation
This option tries to converts clobs or lob into string.
This prevents marimo to access the value of locator and returns the value as a string. It's a good approach but if value is bigger then we expect it can produce an error for time exceeded.