mysqldb simple question (find unique number)

Jacek Popławski jp at ulgo.koti.com.pl
Wed Apr 25 00:25:22 EDT 2001


id_producenta is primary key (int) for table producent
I need to find unique value for it, I use that code:

    dbh.query('select id_producenta from producent');
    res=dbh.store_result()
    how=res.num_rows();
    id=[]
    for i in range(how):
      r=res.fetch_row()
      id=id+[int(r[0][0])]
    del res
    return max(id)+1;

Looks quite long... how to write it in better way?
 
-- 
Now the best steel goes through the fire
And you seem to burn
The dead man's always a liar                              "Hide In The Rainbow"
Look out! there's another one learning!                     - Ronnie James Dio



More information about the Python-list mailing list