Select fails when cookie tried to get a numeric value

MRAB python at mrabarnett.plus.com
Sat Oct 5 12:51:27 EDT 2013


On 05/10/2013 15:44, Zero Piraeus wrote:
> 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?
>
MySQL string interpolation uses "%s" as the placeholder, but the value
doesn't have to be a string.

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



More information about the Python-list mailing list