PDA

View Full Version : SQLITE and REGEXP



miraks
9th March 2011, 12:50
Hi,

In my project, I am using a qslite database opened with QSqlDatabase with "QSQLITE" driver.

I would like to be able to execute a SELECT statement with a REGEXP like:

SELECT * FROM mytable WHERE myattribute REGEXP 'A[0-9]*';

But, as written in sqlite documentation (http://www.sqlite.org/lang_expr.html), the REGEXP function is not implemented by default:

No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message

I know we can implement this function by using sqlite3_create_function but I don't know how to do and if it's the better solution and I would like to avoid prerequisites on sqlite library.

My questions:
Q1-How to add REGEXP implementation on SQLITE driver ?
Q2-Do you know if QT plan to deliver a default implementation of sqlite REGEXP function based on QRegExp ?

Thank you in advance for your help.

miraks
11th March 2011, 08:02
No answer ?

Please help !

unit
11th March 2011, 09:56
rewrite sqlite plugin. or use sqllite in direct way

ChrisW67
16th March 2011, 21:55
Top Google hit for "qt sqlite regexp" is http://lists.trolltech.com/qt-interest/2008-07/thread00466-0.html which explains a little about how to get the necessary Sqlite handle so that you can graft a regexp() impl. into the driver using Sqlite API calls.

I haven't tried this myself yet. I notice there is a Qt bug report requesting this, so I may not have to :)
http://bugreports.qt.nokia.com/browse/QTBUG-18084