Escaping confusion with Python 3 + MySQL

MeV michael.vilain at
Sun Mar 26 09:39:17 EDT 2017

On Sunday, March 26, 2017 at 6:34:30 AM UTC-7, Νίκος Βέργος wrote:
> with import cgitb; cgitb.enable()
> ProgrammingError(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(pagesID, host, ref, location, useros, browser, visits) VALUES (1, '', '' at line 1")
> that is all i get form error. error_log doesnt produce errors when iam trying
> 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) )
> WHY the valued aren't getting substituted wi the aeguments i give it in to work with?

The % construct is Python 2 and no longer supported in Python 3. You should read up on the "{}" and format method.

More information about the Python-list mailing list