Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regex format issue?
#3
(Dec-01-2021, 08:27 PM)bontwoody Wrote:
#This works
cursor.execute('SELECT Word FROM Tbwords WHERE word REGEXP ?',['^.?.?P.?.?.?RE.?.?C.?.?.'])

That's how cursors work. You pass the query, with params to be replaced as "?", and then the values that should be substituted in.

Quote:
#This doesnt
list=['.?.?P.?.?.?RE.?.?C.?.?.']
regex=list[0]
re_end="$']" #end of re mask
re_start="['^" #beginning of re mask
sqltxt="'SELECT Word FROM Tbwords WHERE word REGEXP ?'," + regex
cursor.execute(sqltxt)

You're not passing an argument to the cursor for the value in this example. You've modified your query to end with WHERE word REGEXP ?',regex
bontwoody likes this post
Reply


Messages In This Thread
Regex format issue? - by bontwoody - Dec-01-2021, 08:27 PM
RE: Regex format issue? - by Gribouillis - Dec-01-2021, 09:55 PM
RE: Regex format issue? - by bontwoody - Dec-03-2021, 05:20 PM
RE: Regex format issue? - by nilamo - Dec-03-2021, 01:30 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020