nikos.gr33k at gmail.com
Thu Jan 24 14:24:15 CET 2013
column 'pin' is an 5-digit integer auto_increment primary key.
What i want is to insert a new record or update the existing one, if 'pin' column's value exist. The following statement fails.
cursor.execute( '''INSERT INTO counters(page, hits) VALUES(%s, %s) RETURNING (pin)
ON DUPLICATE KEY UPDATE hits = hits + 1''', (htmlpage, 1) )
Also except from the inserting/updating job, i also need 'pin' colum's value to be extracted from the above statement so to be used to subsequent statement like the following. This is not happening, hence the following statement have no way to find 'pin' column's value which is to be used as a parameter to it.
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))
Can someone correct this please and explain?
More information about the Python-list