【发布时间】:2018-04-27 13:05:12
【问题描述】:
Python 3.6。我正在尝试为 sqlite3 创建一个 REGEXP 函数。我有错误:OperationalError: wrong number of arguments to function REGEXP()
这是我的代码:
import sqlite3
import re
def fonctionRegex(mot):
patternRecherche = re.compile(r"\b"+mot.lower()+"\\b")
return patternRecherche.search(item) is not None
dbName = 'bdd.db'
connexion = sqlite3.connect(dbName)
leCursor = connexion.cursor()
connexion.create_function("REGEXP", 1, fonctionRegex)
mot = 'trump'
data = leCursor.execute('SELECT * FROM tweet WHERE texte REGEXP ?',mot).fetchall()
谢谢
【问题讨论】:
标签: python sql python-3.x sqlite