mysql solution

Duncan Booth duncan.booth at invalid.invalid
Thu Jan 24 10:19:53 EST 2013


Ferrous Cranus <nikos.gr33k at gmail.com> wrote:

> I can do that but then i have to use that pin column's value in my
> next statement. 
> 
> cursor.execute( '''UPDATE visitors SET hits = hits + 1, useros = %s,
> browser = %s, date = %s WHERE pin = %s AND host = %s''', (useros,
> browser, date, pin, host)) 

I'm not MySQL expert, but something like this might work:

cursor.execute('''UPDATE visitors,counter 
SET visitors.hits=visitors.hits+1, visitors.useros=%s,
    visitors.browser =%s, visitors.date=%s
WHERE visitors.pin=counter.pin AND counter.page = %s 
    AND visitors.host=%s''',
   (useros, browser, date, page, host))

-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list