duckdb: [Python] Empty IOException upon installing JSON extension

What happens?

Upon installation of JSON extension in DuckDB an empty IOException with neither stack trace nor error message gets thrown, making it difficult to debug it further. Here is a simplest example of the failing code:

import duckdb

if __name__ == "__main__":
    # sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)  # Running on Windows
    con = duckdb.connect()
    con.execute("INSTALL 'json';")

The process also fails when attempting installation from file:

import duckdb

if __name__ == "__main__":
    # File lies in CWD
    duckdb.install_extension("json.duckdb_extension")

In both cases, all the error information returned is:

Traceback (most recent call last):
  File "c:\dev\projects\openai\debug.py", line 10, in <module>
    con.execute("INSTALL 'json';")
duckdb.IOException

It does not look to me like a problem finding the installation file not a syntax error in my SQL query. Otherwise the DB seems to function properly; I am able to connect, create a test table, insert data and fetch it via the fetchdf method. I am using release 0.7.1 but I got the same error with the 0.7.0, 0.6.1 and 0.7.2.dev1256 versions.

To Reproduce

  1. Create a pipenv environment from the following Pipenv file:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
duckdb = "*"

[dev-packages]

[requires]
python_version = "3.10"
  1. run the following code snippet:
import duckdb

if __name__ == "__main__":
    con = duckdb.connect()
    con.execute("INSTALL 'json';")

OS:

Windows 10

DuckDB Version:

0.7.1

DuckDB Client:

Python

Full Name:

Daniel Moseguí i González

Affiliation:

paiqo GmbH

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I couldn’t quite reproduce your problem, but this code does show (I think, assuming that there should be a “colon: message” after the ParserException) that DuckDB exceptions get truncated under certain conditions:

import duckdb
fstre = "INSTALL 'json';".encode("utf-16")
import os
if __name__ == "__main__":
    con = duckdb.connect()
    con.execute(fstre)

Traceback (most recent call last): File “<mypath>\test.py”, line 18, in <module> con.execute(fstre) duckdb.ParserException

Note the truncated ParserException message.

---- Edit: #6573 gave me an idea, and this also is closer to the error, but I can’t reproduce the error on “install ‘json’” —

import os
import duckdb
os.mkdir("Moseguí_i_González")
os.chdir("Moseguí_i_González")
duckdb.connect("file.db")

Traceback (most recent call last): File “C:\git\simpletesting\pipenv\test.py”, line 5, in <module> duckdb.connect(“file”) duckdb.IOException