also Im figuring ticket # 108 is this same issue, updated with corrections to your test including one feature I havent formally documented yet...except in this post:  http://www.mail-archive.com/sqlalchemy-users@lists.sourceforge.net/msg00478.html

ticket:  http://www.sqlalchemy.org/trac/ticket/108 .

On Mar 10, 2006, at 11:51 AM, Qvx 3000 wrote:

Thanks!

default=func.uuid() works, but I can't say that tracker_key is primary_key when it is not. All foreign keys reference the ID column.

For the time being I manually call uuid() and assign to id during object creation.

Tvrtko

On 3/10/06, Michael Bayer <[EMAIL PROTECTED]> wrote:

you could try:

t = Table('campaigns', engine, 
Column('id', varchar(36), default=func.uuid()),
Column('tracker_key', Integer, primary_key=True)
)


On Mar 10, 2006, at 2:55 AM, Qvx 3000 wrote:

How do I specify that my id column should use UUID() to generate its primary_key?

I'm trying to connect to SugarCRM database with tables that use UUID for primary keys, while also having another auto_increment column. Example:

CREATE TABLE `campaigns` (
  `id` varchar(36) NOT NULL default '',
  `tracker_key` int(11) NOT NULL auto_increment,
  `name` varchar(50) default NULL,
  ...
  PRIMARY KEY  (`id`),
  KEY `auto_tracker_key` (`tracker_key`),
) ;

Imagine also that you have `Campaign` class connected to this table (id column has `primary_key = True`).

If you create new instance of this object `cam = Campaign(name='test')` and commit, you will get the following::
  cam.id # 59L
  cam.tracker_key # None

Which is clearly wrong. It should be:
  cam.id # ''
  cam.tracker_key # 59L


Thanks,
Tvrtko



Reply via email to