mysql solution

Lele Gaifax lele at
Thu Jan 24 12:25:20 CET 2013

Ferrous Cranus <nikos.gr33k at> writes:

> I;am now convinced the hash solution isn't reversible and also isn't
> unique.


> how is the mysql statement is going to find the 'pin' to update the
> specific record.

The simplest way is to execute a SELECT just after the insertion, doing

  SELECT pin FROM counters WHERE page = %s

I don't use MySQL, so I can't say if it supports "INSERT ... RETURNING ..."
SQL syntax: should it, then you could insert the data and fetch
the pin in one shot, with something like

  INSERT INTO counters (page, hits) VALUES (%s, %s) RETURNING (pin)

ciao, lele.
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at  |                 -- Fortunato Depero, 1929.

More information about the Python-list mailing list