How to create a custom function in QSqlDatabase: regex in sqlite and PyQT

Define a REGEXP function of type python in sqlite and python after Problem with regexp python and sqlite

How can we do the same in PyQT, i.e. with QSqlDatabase?

More precisely, we use the REGEXP function to create the view:

Create view temp as select * from somewhere where columnname REGEXP 'myregex';

This works well while we make a selection from Python. We want to show the result in QTableView(through a QSqlTableModel, filled with the view). Since the view uses REGEXP, we need to associate the Python regex function with QSqlDatabase.

+5
source share

All Articles