[sqlalchemy] (Semi-)automated way to adjust constraint names via Alembic?
So, in my ongoing quest to make my team's operations database far more sane than it currently is, I want to fix all the constraint naming in the database to match the naming convention setting I have added to my SQLAlchemy configuration for the database. I could of course go through each table and determine each by hand, but I was wondering if there was a less manual (and error-prone) way to approach this, possibly via the autogeneration feature? In case it matters, the database server is MySQL. -- - Ken Lareau -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] (Semi-)automated way to adjust constraint names via Alembic?
Well you can get at the names that were used in the DB (using Inspector, or reflection) as well as the names that are in your metadata ([constraint for constraint in table.constraints for table in metadata.tables.values()], but as far as matching them up I'm not sure, it depends on what patterns you can find in the existing DB that you can use. maybe you can write a script that guesses, then it spits out a list of oldname-newname, then you can manually correct it. On 7/2/14, 6:08 PM, Ken Lareau wrote: So, in my ongoing quest to make my team's operations database far more sane than it currently is, I want to fix all the constraint naming in the database to match the naming convention setting I have added to my SQLAlchemy configuration for the database. I could of course go through each table and determine each by hand, but I was wondering if there was a less manual (and error-prone) way to approach this, possibly via the autogeneration feature? In case it matters, the database server is MySQL. -- - Ken Lareau -- 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 mailto:sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com mailto:sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] (Semi-)automated way to adjust constraint names via Alembic?
On Wed, Jul 2, 2014 at 6:44 PM, Mike Bayer mike...@zzzcomputing.com wrote: Well you can get at the names that were used in the DB (using Inspector, or reflection) as well as the names that are in your metadata ([constraint for constraint in table.constraints for table in metadata.tables.values()], but as far as matching them up I'm not sure, it depends on what patterns you can find in the existing DB that you can use. maybe you can write a script that guesses, then it spits out a list of oldname-newname, then you can manually correct it. Heh, very few patterns to be found, sadly. I could easily create a tabular set of data that would allow me to map names to the type of constraint and hope- fully that would be enough for me to run through them all; the biggest issues I suspect will be the multi-column constraints along with the primary keys (since it seems that MySQL uses 'PRIMARY' for the name of the constraint and I'm not even sure that's changeable (been putting together a test data- base to try it out on)). But I'll see what I can hack together. :) - Ken On 7/2/14, 6:08 PM, Ken Lareau wrote: So, in my ongoing quest to make my team's operations database far more sane than it currently is, I want to fix all the constraint naming in the database to match the naming convention setting I have added to my SQLAlchemy configuration for the database. I could of course go through each table and determine each by hand, but I was wondering if there was a less manual (and error-prone) way to approach this, possibly via the autogeneration feature? In case it matters, the database server is MySQL. -- - Ken Lareau -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- - Ken Lareau -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.