I want to add a function to SQLite in Python (like explained here)
My function returns multiple values. In python, I can access to different return values by indexing (using []).
However, it seems indexing does not work in SQLite. In other words, the following SELECT statement will have an error:
SELECT my_function(table1.column1)[0] FROM table1;
sqlite3.OperationalError: user-defined function raised exception
Is there any way to access to different return values in SQLite?
The only way to return multiple values from a function is with a table-valued function, which requires creating a virtual table module, which is not possible with only the default Python SQLite driver.
There are additional Python modules to allow this, for example, sqlite-vtfunc.