Escaping confusion with Python 3 + MySQL

Νίκος Βέργος me.on.nzt at gmail.com
Sun Mar 26 10:43:51 EDT 2017


Τη Κυριακή, 26 Μαρτίου 2017 - 5:38:57 μ.μ. UTC+3, ο χρήστης alister έγραψε:
> On Sun, 26 Mar 2017 07:24:49 -0700, Νίκος Βέργος wrote:
> 
> > Τη Κυριακή, 26 Μαρτίου 2017 - 5:19:27 μ.μ. UTC+3, ο χρήστης Ian έγραψε:
> > 
> >> You need to change the placeholders back. The poster who told you to
> >> replace them was misinformed.
> > 
> > okey altered them back to
> > 
> > cur.execute('''UPDATE visitors SET (pagesID, host, ref, location,
> > useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host
> > LIKE "%%s%" ''',
> > 
> 																																			
> (pID, domain, ref, location, useros,
> > 
> 																																			
> browser, lastvisit, domain) )
> > 
> > but now the problem is how to exact;y type the Where HOST like "%%%"
> > 
> > I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.
> 
> 
> as a quick thought (untested) it is probably best to have %s as your 
> parameter for the Like clause & ad the sql wild-cards (% symbols) to the 
> data you pass in as I think the expansion of %s adds quote marks which 
> will certainly cause the sql parser issues.

How do you propose writing that cur.execute statement Alister?




More information about the Python-list mailing list