A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/083618.html below:

[OFF TOPIC] Re: mysqldb simple question (find unique number)

[OFF TOPIC] Re: mysqldb simple question (find unique number)Bob Kline bkline at rksystems.com
Thu Apr 26 13:26:43 EDT 2001
On Thu, 26 Apr 2001, Brian Langenberger wrote:

> : Of course, you will realise that problems might arise should any two users
> : concurrently try to use any such routine, since NySQL (as far as I remember)
> : does not support transactions.
> 
> It might be better to simply use MySQL's "auto_increment" tag for
> the key column.  That way, one can simply use "0" as the ID number
> and MySQL will automatically generate a new, unique ID.
> 
> Of course, if you need to return that same ID again for other 
> purposes, you'll need the max() function along with some table 
> locking before and aftwarwards (to keep the process atomic).  

This is really in the wrong mailing list [1] for this discussion, but I
believe MySQL supports what is needed here without the need for table
locking.  Take a look at the documentation [2] for the LAST_INSERT_ID()
function, which returns the last automatically generated value that was
inserted into an AUTO_INCREMENT column on a per-connection basis.

[1] http://www.mysql.com/documentation/lists.html
[2] http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Miscellaneous_functions

-- 
Bob Kline
mailto:bkline at rksystems.com
http://www.rksystems.com



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4