Great, thank you. Managed to make it work! On Wednesday, May 6, 2020 at 2:35:12 PM UTC+2, Mike Bayer wrote: > > > > On Wed, May 6, 2020, at 7:19 AM, Alejandro Avilés wrote: > > I'm working on a project where I need to add additional columns to tables > defined in a different package. This is done via monkeypatching the model > classes. I need now to also add additional constraints, but I'm getting no > luck overriding `__table_args__`. > > I'm a bit lost as to how to continue investigating, so my two questions > are: > - Is SA taking into account `__table_args__` only once per model class? > > > yes, this is based on a metaclass at class creation time > > > - Is there any way to define new constraints outside the model class? > > > yes you should work against the table directly: > > mymodel.__table__.append_constraint(Index(...)) > > > > > > Any suggestion/lead on how to do this differently will also be appreciated. > Thanks in advance! > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlal...@googlegroups.com <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/2203e8d5-62e3-4a80-b453-489f4492d022%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/2203e8d5-62e3-4a80-b453-489f4492d022%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > >
-- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/d460609d-b4db-41f8-93bc-9c1705230a43%40googlegroups.com.