1. Michael Bayer
  2. alembic
  3. Issues

Issues

Issue #23 resolved

Alembic inconvenient to use programmatically

Daniel Miller
created an issue

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.

Comments (1)

  1. Michael Bayer repo owner

    The config file dependency is an oversight and is resolved in 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.

  2. Log in to comment