[Twisted-Python] serial datatype in t.e.row

Sean Riley sean at twistedmatrix.com
Sat Sep 7 14:21:40 EDT 2002

I have been looking at adding support for "serial" columns into
twisted.enterprise.row and it appears to be harder than i originally

Serial columns auto-increment when a row is inserted so that the application
doesnt have to manage the value of the index manually. So:

	  column1  serial,
	  column2  int

	INSERT INTO mytable (column2) VALUES (33);

will actually auto-increment the sequence for "column1" and use the next

But.. using twisted enterprise:

	newRow = MyRow()

does effectively the same thing, but the newRow object doesn't know the
value of the index column (column1 in this case) that was just inserted, so
it doesn't know how to update or delete itself!

One solution may be to manually run a

	SELECT nextval('sequencename')

to get the next value and use that for the insert, but this requires an
extra step for each insert, and requires that the we know which tables have
serial columns (suprisingly hard to figure out..) and makes the behavior for
tables with serial columns and no serial columns very different.

Also, the behavior of auto-incrementing key columns is different for every
database implementation...

"If he's so smart, then how come he's dead?", Homer Simspon
Sean Riley
sean at ninjaneering.com

More information about the Twisted-Python mailing list