I Don't how to that in PyQt, in C++ Qt:
You need to wirte a function to do pattern matching for you, example:
void qtregexp(sqlite3_context* ctx, int argc, sqlite3_value** argv)
{
QString str1
((const char*)sqlite3_value_text
(argv
[0]));
QString str2
((const char*)sqlite3_value_text
(argv
[1]));
regex.setPattern(str1);
regex.setCaseSensitivity(Qt::CaseInsensitive);
bool b = str2.contains(regex);
if (b)
{
sqlite3_result_int(ctx, 1);
}
else
{
sqlite3_result_int(ctx, 0);
}
}
void qtregexp(sqlite3_context* ctx, int argc, sqlite3_value** argv)
{
QRegExp regex;
QString str1((const char*)sqlite3_value_text(argv[0]));
QString str2((const char*)sqlite3_value_text(argv[1]));
regex.setPattern(str1);
regex.setCaseSensitivity(Qt::CaseInsensitive);
bool b = str2.contains(regex);
if (b)
{
sqlite3_result_int(ctx, 1);
}
else
{
sqlite3_result_int(ctx, 0);
}
}
To copy to clipboard, switch view to plain text mode
Then you need to get the handle to the SQLite database somehow, one way is to use SQLite's API, example:
sqlite3 *sldb;
sqlite3_open(":memory:", &sldb);
sqlite3 *sldb;
sqlite3_open(":memory:", &sldb);
To copy to clipboard, switch view to plain text mode
Last step is a call to sqlite3_create_function, example:
sqlite3_create_function(sldb, "REGEXP", 2, SQLITE_UTF8, NULL, &qtregexp, NULL, NULL);
sqlite3_create_function(sldb, "REGEXP", 2, SQLITE_UTF8, NULL, &qtregexp, NULL, NULL);
To copy to clipboard, switch view to plain text mode
Hope this helps
Bookmarks