Re: [sqlalchemy] How to customize base declarative class to add naming conventions

2018-09-05 Thread Derek Lambert
Just define the naming convention dict in a separate file and import it into each declarative base? On Wednesday, September 5, 2018 at 4:18:44 AM UTC-5, René-paul Debroize wrote: > > It would have been great to be able to do it via a mixin, I have several > DB using decalarative base

Re: [sqlalchemy] How to customize base declarative class to add naming conventions

2018-09-05 Thread René-paul Debroize
It would have been great to be able to do it via a mixin, I have several DB using decalarative base constructed with this Base mixin and I liked to have the same naming_convention for all the DBs without repeating myself. If it's not I guess i can still manage to find an acceptable way of doing it

Re: [sqlalchemy] How to customize base declarative class to add naming conventions

2018-09-04 Thread Simon King
On Tue, Sep 4, 2018 at 3:48 PM wrote: > > I'd like to create a mixin to specify naming conventions. > > I tried both: > > class Base: > metadata = MetaData(naming_convention={ > "ix": "ix_%(column_0_label)s", > "uq": "uq_%(table_name)s_%(column_0_name)s", > "ck":

[sqlalchemy] How to customize base declarative class to add naming conventions

2018-09-04 Thread rdebroiz
I'd like to create a mixin to specify naming conventions. I tried both: class Base: metadata = MetaData(naming_convention={ "ix": "ix_%(column_0_label)s", "uq": "uq_%(table_name)s_%(column_0_name)s", "ck": "ck_%(table_name)s_%(constraint_name)s", "fk":