I have a Postgres-backed website, and use REGEXP_REPLACE
to replace the first instance of a value in some columns. This is fine. The problem comes where I need to run CI, and for one reason and another (limitations of Github Actions and Windows VMs), I can't use Postgres in my tests.
Choosing SQLite produced a few test failures, and I realised that SQLite doesn't have REGEXP_REPLACE
built in.
def do_execute(self, cursor, statement, parameters, context=None):
> cursor.execute(statement, parameters)
E sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such function: regexp_replace
E [SQL: SELECT job_site.created_at AS job_site_created_at, ..., job_site.neighborhood_id AS job_site_neighborhood_id
E FROM job_site
E WHERE regexp_replace(job_site.name, ?, ?) = ?]
E [parameters: (' - ', ':', 'BGS:NEEA - 1894 - 05700 Brown Islands Suite 681')]
E (Background on this error at: http://sqlalche.me/e/e3q8)
How can I add this function to SQLite in SQLAlchemy?