Superintendent UI
Superintendent UI

Reputation: 81

How do I configure alembic.ini path correctly?

When I run any alembic commands, I get the following error:

FAILED: No config file 'alembic.ini' found, or file has no '[alembic]' section

According to the documentation, I need to set my path so I did. I'm running WSL Ubuntu 18.

Am I setting the path wrong? I run the commands in my flask project's top directory: ~/microblog$

My alembic file structure is:

~/microblog/
 - migrations/
  -- __pycache__/
  -- versions/
  -- alembic.ini
  -- env.py
  -- README
  -- script.py.mako

alembic.ini

# A generic, single database configuration.

[alembic]
script_location = home/acanizales1/microblog/migrations/alembic
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false


# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
... the rest below are configured correctly ...

Thank you.

Upvotes: 3

Views: 6275

Answers (3)

Jose Javier Soto
Jose Javier Soto

Reputation: 31

Make sure that you have initialized Alembic.

Try running the following command:

alembic init alembic

Upvotes: 0

pxul
pxul

Reputation: 517

TIL that you can use %(here)s in alembic.ini to specify a script_location relative to alembic.ini.

Further details here: https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file.

Upvotes: 0

niid
niid

Reputation: 518

From the doc:

script_location - this is the location of the Alembic environment. It is normally specified as a filesystem location, either relative or absolute. If the location is a relative path, it’s interpreted as relative to the current directory.

So in your case, because the path does not start with a "/" it is interpreted as relative to the current working directory.

This is confusing, because it is not relative to the ini file, but relative to the path where you are executing the alembic command from.

Also, you should make sure that the "alembic" folder actually exists under that path by running alembic init alembic [see the docs]

Upvotes: 0

Related Questions