[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Michael Bayer
Gregg Lind wrote: I use declarative base for defining classes. I have a constraint that only works in Postgres. How do I declare that constraint lowername_check only if the session is going postgres (and not to sqlite, for example). pg_only_constraint = CheckConstraint(lowername !~

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Gregg Lind
As always, thank you for the complete, exhaustive answer. This particular thing is definitely and edge case, and rather non-obvious, so thank you for walking me through it. Either of those are clean enough for me! Is there are more proper / general way to describe the problem, so google and

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Michael Bayer
Gregg Lind wrote: I used the DDL style DDL('''ALTER TABLE data ADD CONSTRAINT lowername_check CHECK (lowername !~ '[[\:upper\:]]')''', on=postgres).execute_at('after-create',Data.__table__) and now my print_schema method (based on

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Gregg Lind
Alas, that doesn't seem to matter or help. Even this statement causes the same issue. Odd. Must not be related to the colons, alas. DDL(r''' ''', on=postgres).execute_at('after-create',Data.__table__) On Fri, May 29, 2009 at 3:08 PM, Michael Bayer mike...@zzzcomputing.com wrote: Gregg

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Michael Bayer
Gregg Lind wrote: Alas, that doesn't seem to matter or help. Even this statement causes the same issue. Odd. Must not be related to the colons, alas. DDL(r''' ''', on=postgres).execute_at('after-create',Data.__table__) didnt realize you're printing with mock. its: buf.write(str(s) +

[sqlalchemy] Re: Declarative base -- only add a constraint if particular db engine

2009-05-29 Thread Michael Bayer
mock is on the way out as a general use tool. Gregg Lind wrote: You got me there! Updating the FAQ on it would fix the issue for others. For reference: ## from sqlalchemy import * from sqlalchemy.schema import DDL from sqlalchemy.ext.declarative import