the only working "ID generator" we have right now is the Sequence object, which obviously is only useable in postgres and oracle, and it is capable of being called in a standalone fashion.
Additionally, the ColumnDefault object (of which Sequence shares a common baseclass of "DefaultGenerator") is created whenever you specify the "default" keyword argument on Column, and you can also specify these explicitly. a ColumnDefault is designed so that you can stick any SQL call or Python callable that will be called to generate new values; and like the Sequence, it also can be called standalone (either via sometable.c.somecolumn.somedefault.execute() or engine.connect().execute(somedefault) ). so the hooks are there, the actual generator algorithms other than Sequence are not. if you can come up with some useful ID generator functions, they can be added to the sqlalchemy.ext package. for databases like mysql, im not really familiar with a good atomic method of creating new table ID's externally to those automatically generated (i.e. calling select max(id) from table is not really atomic....) On Sep 6, 2006, at 9:15 AM, Lars Heuer wrote: > Hi, > > [Hibernate] and other ORMs provide some kind of [IdGenerator] that are > used to generate primary identifiers without (in most cases) querying > a database table. > > Actually, in one app I need an ID immediately, so an ID generator > would be very helpful. Does something like that exist already? > > As work around I use something like this: > > sess.save(myNewObject) > sess.flush([myNewObject]) > > which works fine. But if I create more objects that should be flushed > in one transaction I run into dependency problems / errors. > > > [Hibernate] http://www.hibernate.org/ > [IdGenerator] <http://www.allapplabs.com/hibernate/ > hibernate_o_r_mapping_generator_element.htm> > > Thanks and best regards, > Lars > -- > http://www.semagia.com > > > ---------------------------------------------------------------------- > --- > Using Tomcat but need to do more? Need to support web services, > security? > Get stuff done quickly with pre-integrated technology to make your > job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel? > cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Sqlalchemy-users mailing list > Sqlalchemy-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users