Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I expect Python sqlite3 user defined functions to persist in a SQLite database?

Tags:

python

sqlite

I register a user defined function:

conn.create_function("geocode", 4, geocode)

The function is used in a trigger, and the trigger fires correctly after an insert, but the function isn't found:

sqlite3.OperationalError: no such function: geocode

My understanding of this usage pattern may be wrong, is it possible to persist Python functions in the database?

like image 273
Bruce Harold Avatar asked Oct 18 '25 13:10

Bruce Harold


1 Answers

The documentation says:

If an application uses more than one database connection then application-defined SQL functions must be added to each database connection separately.

And how could your Python code persist when you can open the same database file later on some other machine?

like image 75
CL. Avatar answered Oct 21 '25 02:10

CL.