Select fails when cookie tried to get a numeric value

Zero Piraeus z at etiol.net
Sat Oct 5 10:44:18 EDT 2013


:

On Sat, Oct 05, 2013 at 05:30:53PM +0300, Νίκος Αλεξόπουλος wrote:
> Every mysql statemtns that involved cookieID fails.
> 
> in this example this:
> 
> # find the visitor record for the (saved) cID and current host
> cur.execute('''SELECT * FROM visitors WHERE counterID = %s and
> cookieID = %s''', (cID, cookieID) )
> data = cur.fetchone()        #cookieID is unique

If every cur.execute() invocation that you try to pass cookieID to
fails, that suggests you can't pass cookieID to cur.execute() ...
perhaps because it's the wrong type.

The use of '%s' string interpolation suggests that cur.execute() is
expecting a string. Is cookieID a string? If not, is it some kind of
object that contains a string value within it? Maybe it has some kind of
attribute you could pass, like cookieID.value or similar?

That may or may not be correct, but it's the kind of mental process you
should be going through to solve your problem.

 -[]z.

-- 
Zero Piraeus: inter caetera
http://etiol.net/pubkey.asc



More information about the Python-list mailing list