7

We define the python type REGEXP function in sqlite and python following Problem with regexp python and sqlite

How can we do the same thing in PyQT, ie. with a QSqlDatabase?

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

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

This works well, as long as we do the select from Python. We would like to show the result in a QTableView (via a QSqlTableModel filled with the view). As the view uses the REGEXP, we would have to link the Python regex function to the QSqlDatabase.

2
  • Unfamiliar with Qt but this question is unanswered for 2 years so what the heck: Can't QSqlTableModel select from the sqlite view? So QSqlTableModel "thinks" it's consulting a table for QTableView, but it's actually consulting the view which already has the regex in it? (I realize this might be nonsense, please don't sue) Commented Aug 25, 2014 at 15:12
  • Regexp support can be enabled via the database connection options (i.e. QSQLITE_ENABLE_REGEXP). Commented Oct 19, 2022 at 11:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.