You probably need to override the autoloaded primary key column: http://www.sqlalchemy.org/docs/04/metadata.html#metadata_tables_reflecting_overriding
Specify the type with MSUniqueIdentifier from sqlalchemy.databases.mssql On Sep 11, 9:01 am, Smoke <[EMAIL PROTECTED]> wrote: > Hi All, > > I'm new to sqlalchemy and was checking if i can introduce it into some > of my projects... I have some database ( sql server ) tables with > MSUniqueidenfier columns set as PK and with newid() as default > values... > So, if i try to map this table into a class,save a new record and > flush, then i have errors because it says that column doesn't support > NULL values.. > Is there any option i'm missing that can make me exclude this PK from > the INSERT query or somehow tell sqlalchemy that this pk column value > is autogenerated by the database? > > thanks, > FP > > P.S.: > > My code is something very simple... like this: > > t = sa.Table("Machines", metadata, autoload=True) > Session = sessionmaker(bind=db, autoflush=False, transactional=False) > class Machine(object): > pass > > session = Session() > sa.orm.mapper(Machine, t)#, exclude_properties=['uId']) > m = Machine() > > nm = Machine() > nm.name, nm.node = "Mac1", "P" > session.save(nm) > session.flush() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---