Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Alembic inconvenient to use programmatically #23
Migrated issue, originally created by Daniel Miller (@millerdev)
I'd like to call alembic commands programmatically, but the config object is proving rather difficult to use that way. Here's my use case: I want to write tests for my migrations. I'd like to use alembic to down/upgrade the database to a particular revision and then run some tests on the db to verify that things look right. Am I overlooking something obvious, or is there no good way to make alembic do its thing without a config file on disk?
The root of the problem seems to be the tight coupling to ConfigParser, as a fundamentally file-based structure. It would be nice to support a simpler programmatic configuration object such as a plain dict.
Michael Bayer (@zzzeek) wrote:
The config file dependency is an oversight and is resolved in [[https://bitbucket.org/zzzeek/alembic/changeset/38368e8f9a306ba9dfa668dcc8cfaef5d2f031b1|38368e8f9a306ba9dfa668dcc8cfaef5d2f031b1]]. The file no longer needs to be passed, the existing method set_main_option() as well as a new method set_section_option() can be used to assign values (or not).
Plain dict is a little tougher here since we are using sections. It is possible to make individual sections available as dictionaries, or maybe use a dictionary of dictionaries, though this seems a little redundant... Python's config parser just provides the one interface.