I want to use alembic.py for configuration instead of alembic.ini.
But I can't find any example of that type of configuration.
Is there any way to not use alembic.ini?
Asked
Active
Viewed 326 times
1

Jony cruse
- 815
- 1
- 13
- 23
1 Answers
4
Are you looking for this:
from alembic.config import Config
alembic_cfg = Config()
alembic_cfg.set_main_option("script_location", "myapp:migrations")
alembic_cfg.set_main_option("url", "postgresql://foo/bar")
alembic_cfg.set_section_option("mysection", "foo", "bar")

Sait
- 19,045
- 18
- 72
- 99
-
This is exactly what I wanted. How can I specify this custom config `.py` file when execute alembic command? – Jony cruse Jul 06 '15 at 06:29
-
Save this file as `alembic_config_file.py` and import it from your application in the beginning. – Sait Jul 06 '15 at 07:11
-
1Also please consider [upvoting](http://meta.stackexchange.com/questions/173399/how-to-upvote-on-stack-overflow) or marking it answer by clicking the tick if it helped you. – Sait Jul 06 '15 at 07:12
-
The new document Url can be found at https://alembic.sqlalchemy.org/en/latest/api/config.html – sparrow Mar 06 '19 at 09:15