mysql solution

Lele Gaifax lele at metapensiero.it
Thu Jan 24 06:25:20 EST 2013


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

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

Great!

> 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
a

  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 metapensiero.it  |                 -- Fortunato Depero, 1929.




More information about the Python-list mailing list