I'm trying to extend SQLite in Python. So I have several of these:
connection.create_function("MICROSECONDS_SUB", 2, microseconds_sub)
corresponding to python implementations:
def microseconds_sub(date, microseconds)
# some kind of logic to subtract microseconds from a date
I'd like to be able to supply functions that can take optional arguments (for example, two required arguments and a third optional one), but I'm not sure how.
You can pass
-1for the number of arguments to prevent SQLite from doing any verification on the number of arguments.If the function accepts whatever is passed to it, then the call will succeed, otherwise, it'll throw a sqlite3.OperationalError.