[Twisted-Python] Enterprise Rowobject and generating primary keys
Clark C. Evans
cce at clarkevans.com
Thu May 27 20:03:59 EDT 2004
as I remember, nextval is garuenteed to be unique (but
definately not sequential) across transactions. Why not
just fetch your own value and use it as the key?
c = pgsql.cursor()
or is your question more subtle?
On Thu, May 27, 2004 at 11:25:39PM +0200, Guenther Starnberger wrote:
| Hi all,
| I have a problem creating primary key values for enterprise rowobjects.
| The KeyFactory class says "This is deprecated. Use the underlying
| database to generate keys, or just roll your own.". As I am using
| Postgresql the ideal solution would be to just use the 'nextval'
| function (which is used as default value for the primary key in my
| schema, therefore I could skip this column in my insert statement).
| The problem now is, that I need to assign a value to the rowobject
| primary key column, otherwise i get an exception from twisted
| ('instance has no attribute...'). Just excluding the primary key
| column from my rowColumns attribute doesn't work either as this
| results in twisted to hang. Manually selecting the nextval function
| with the adbapi and using the result as primary key works, but this
| solution isn't really nice.
| Any other proposals for an elegant solution to create primary keys
| when inserting new rowobjects?
| Twisted-Python mailing list
| Twisted-Python at twistedmatrix.com
Clark C. Evans Prometheus Research, LLC
Chief Technology Officer Turning Data Into Knowledge
cce at prometheusresearch.com www.prometheusresearch.com
(main) 203.777.2550 (cell) 203.444.0557
More information about the Twisted-Python