[Zope] q: How should I get a guaranteed unique id in Zope?

Farrell, Troy troy.farrell@wcg.com
Tue, 15 Jan 2002 08:22:36 -0600


Somebody give the man a cookie!
Joe, when you create the table, use the serial type:

CREATE TABLE tableLogfileList(
  logfile_id SERIAL PRIMARY KEY,
  logfile_path TEXT NOT NULL,
  logfile_size INTEGER NOT NULL,
  logfile_time INT8 NOT NULL,
  logfile_md5 CHAR(32),
  logfile_errors INT2)

Then, to add data, just ignore the id like this:
INSERT INTO tableLogfileList (
  logfile_path,
  logfile_size,
  logfile_time,
  logfile_md5,
  logfile_errors
) VALUES (
'/usr/local/logs/new-reports.ibeam.com/vyvx_williamsenl/NetShow.010401-01040
2.log'
11171,
988365240,
'a09ff0a4b11142d03ea940e83a94c82a',
0)

See some techdocs on Postgresql (good choice):
http://www.postgresql.org/idocs/index.php?datatype.html#DATATYPE-NUMERIC
As you can tell, I prefer real world examples :)

Troy