Escaping confusion with Python 3 + MySQL

Chris Angelico rosuav at gmail.com
Sun Mar 26 23:00:20 EDT 2017


On Mon, Mar 27, 2017 at 1:52 PM, Νίκος Βέργος <me.on.nzt at gmail.com> wrote:
> Its NOT that i have not read it exactly, but for some strange reason i was under the belief that the way i had syntactically typed the UPDATE query was correctly and more consistent and similar to thr INSERT query and it was prefered to me over the other one.
>
> UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s"
>
> Its still a mystery to em whay this fails syntactically when at the same time INSERT works like that.
>
> We give each columnn a specific value i don't see why it must only be written as UPDATE visitors SET a=1, b=2, c=3 ... WHERE host LIKE %s.
>
> i knew that would work, but the first way although proven syntactically wrong seems so right .....

It'd be even more logical to write:

UPDATE visitors INCREMENT visits WHERE host CONTAINS %s;

I should just use that syntax, and if it doesn't work, I'm going to
post onto a mailing list until it magically starts working. It's NOT
that I haven't read the docs - I'm just going to wilfully ignore them.

Okay, I'm done now.

ChrisA



More information about the Python-list mailing list