R: Re: [sqlalchemy] dialect sensible declaration

2012-07-16 Thread matteo . boscolo
TIM: la tua mail in mobilità con il BlackBerry® -- 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 sqlalchemy+unsubscr...@googlegroups.c

R: Re: [sqlalchemy] dialect sensible declaration

2012-07-16 Thread matteo . boscolo
W TIM: la tua mail in mobilità con il BlackBerry® -Original Message- From: alex bodnaru Sender: sqlalchemy@googlegroups.com Date: Mon, 16 Jul 2012 18:51:28 To: Reply-To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] dialect sensible declaration thank you very much michael

Re: [sqlalchemy] dialect sensible declaration

2012-07-16 Thread alex bodnaru
thank you very much michael. both ways worked like a charm. i have implemented the other way, though this is better and more general: any constraint with onupdate or ondelete attributes should have these attributes set to none if the dialect name is mssql. thanks a lot, alex On 07/16/2012 05:1

Re: [sqlalchemy] dialect sensible declaration

2012-07-16 Thread Michael Bayer
oh also your foreign_keys is wrong. PageData has a foreign key to Lang. So foreign_keys=[lang_code], lose the "uselist" which is never necessary except for one-to-one. On Jul 16, 2012, at 5:18 AM, alex bodnaru wrote: > > hello michael, friends, > > here is my test case. > thanks a lot for y

Re: [sqlalchemy] dialect sensible declaration

2012-07-16 Thread Michael Bayer
thanks - though one thought I had is, why not just modify an existing ForeignKeyConstraint.onupdate directly in the event, instead of trying to add the constraint later and confusing the ORM. you wouldn't need the relationship arguments then. the constraints for the table are in table.constrai

Re: [sqlalchemy] dialect sensible declaration

2012-07-16 Thread alex bodnaru
hello michael, friends, here is my test case. thanks a lot for your consideraion. please take a look. from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, Unicode, ForeignKeyConstraint from sqlalchemy.orm im

Re: [sqlalchemy] dialect sensible declaration

2012-07-15 Thread Michael Bayer
On Jul 15, 2012, at 5:53 AM, alex bodnaru wrote: > > hello michael, friends, > > On 07/11/2012 10:31 AM, alex bodnaru wrote: >> >> hello michael, >> >> now it works. i also had to add uselist=False. >> >> i tried it the longest way possible, by adding a Pool first_connect listener, >> but th

Re: [sqlalchemy] dialect sensible declaration

2012-07-15 Thread alex bodnaru
hello michael, friends, On 07/11/2012 10:31 AM, alex bodnaru wrote: > > hello michael, > > now it works. i also had to add uselist=False. > > i tried it the longest way possible, by adding a Pool first_connect listener, > but this was not really needed. just the uselist. > > thanks a lot, > a

Re: [sqlalchemy] dialect sensible declaration

2012-07-11 Thread alex bodnaru
hello michael, now it works. i also had to add uselist=False. i tried it the longest way possible, by adding a Pool first_connect listener, but this was not really needed. just the uselist. thanks a lot, alex On 07/09/2012 04:25 PM, Michael Bayer wrote: > > On Jul 9, 2012, at 4:48 AM, alex bo

Re: [sqlalchemy] dialect sensible declaration

2012-07-09 Thread Michael Bayer
On Jul 9, 2012, at 4:48 AM, alex bodnaru wrote: > > hello michael, friends, > > after successfuly fixing the ddl by the append_constraint event, the relations > that needed the said foreign keys remained orphan, asking for a foreign_keys > argument and failing to load the remote table: > > cla

Re: [sqlalchemy] dialect sensible declaration

2012-07-09 Thread alex bodnaru
hello michael, friends, after successfuly fixing the ddl by the append_constraint event, the relations that needed the said foreign keys remained orphan, asking for a foreign_keys argument and failing to load the remote table: class Lang(DeclarativeBase): lang_code = Column(String(20), prima

Re: [sqlalchemy] dialect sensible declaration

2012-07-08 Thread alex bodnaru
it worked very well, thanks a lot michael :), alex On 07/07/2012 05:13 PM, Michael Bayer wrote: > sure engine and connection have .dialect.name. Foreign key constraints > don't matter on SQLite unless you've actually enabled them, which is rare. > I'd still use an event though so at least

Re: [sqlalchemy] dialect sensible declaration

2012-07-07 Thread alex bodnaru
thanks a lot michael. i think i'll go this way :) best regards, alex On 07/07/2012 05:13 PM, Michael Bayer wrote: > sure engine and connection have .dialect.name. Foreign key constraints > don't matter on SQLite unless you've actually enabled them, which is rare. > I'd still use an event

Re: [sqlalchemy] dialect sensible declaration

2012-07-07 Thread Michael Bayer
sure engine and connection have .dialect.name. Foreign key constraints don't matter on SQLite unless you've actually enabled them, which is rare. I'd still use an event though so at least the behavior is transparent. @event.listens_for(my_table, "before_create") def add_fk(table, conn, **kw)

Re: [sqlalchemy] dialect sensible declaration

2012-07-06 Thread alex bodnaru
hello mike and thanks for your answer. no problem with ForeignKeyConstraint, but wouldn't AddConstraint go the alter way? in this case, it will be ignored by the sqlite dialect. what i was looking for was more like: from sqlalchemy... import get_dialect fk_parms = dict(.) if get_diale

Re: [sqlalchemy] dialect sensible declaration

2012-07-06 Thread Michael Bayer
you'd use ForeignKeyConstraint along with the AddConstraint directive, and limit it per-dialect using create/drop events as documented at http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#controlling-ddl-sequences . On Jul 6, 2012, at 1:30 PM, alex bodnaru wrote: > > hello friends, > >

[sqlalchemy] dialect sensible declaration

2012-07-06 Thread alex bodnaru
hello friends, i need to define a foreign key differently for different dialects: ondelete='restrict' for most engines, but nothing (implied and not recognized) for mssql. could you help? thanks in advance, alex -- You received this message because you are subscribed to the Google Groups "sq