Still have problems... if i change:
t = sa.Table("Machines", metadata, autoload=True) to: t = sa.Table("Rpm_MacchineConfig", metadata, sa.Column('uId', sa.databases.mssql.MSUniqueIdentifier, primary_key=True), autoload=False) i have: sqlalchemy.exceptions.DBAPIError: (ProgrammingError) ('42000', "[42000] [Microso ft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'. (102)") u'INSERT INTO [Rpm_MacchineConfig] () VALUES ()' [] and if i put autoload= True, like this: t = sa.Table("Rpm_MacchineConfig", metadata, sa.Column('uId', sa.databases.mssql.MSUniqueIdentifier, primary_key=True), autoload=True) i have this: sqlalchemy.exceptions.DBAPIError: (IntegrityError) ('23000', "[23000] [Microsoft ][ODBC SQL Server Driver][SQL Server]Impossible to insert NULL value into column 'uId' on table 'dbtests.dbo.Rpm_MachineConfig'.The column does not support NULL values.... (515); [01000] [Microsoft][O DBC SQL Server Driver][SQL Server]Instruction interrupted. (3621)") u 'INSERT INTO [Rpm_MacchineConfig] (nome, nodo, descrizione) VALUES (?, ?, ?)' ['MARIO', 'FI', None ] Any hint before i start changing my table design? I'm a newbie on sqlalchemy so i'm probably missing something... thanks FP On 12 Set, 02:18, KyleJ <[EMAIL PROTECTED]> wrote: > You probably need to override the autoloaded primary key > column:http://www.sqlalchemy.org/docs/04/metadata.html#metadata_tables_refle... > > 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 -~----------~----~----~----~------~----~------~--~---