Escaping confusion with Python 3 + MySQL

Frank Millman frank at chagford.com
Sun Mar 26 10:07:34 EDT 2017


"Νίκος Βέργος"  wrote in message 
news:8c5f0443-c61b-4059-8d6f-576152d5932d at googlegroups.com...

>
> 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) )
>
> As if i have a syntactical error in someplace which i'am faling to see or 
> PyMySQL wants special treatment regarding escaping special characters.
>

I don't know MySQL, but for most RDBMS's, the construction you show only 
works for INSERT statements.

For UPDATE, you usually have to say -
    UPDATE {table} SET col_1 = val_1, col_2 = val_2 WHERE col_3 = val_3 ...

Frank Millman





More information about the Python-list mailing list