alembic revision --autogenerate 오

alembic revision --autogenerate
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\venvs\testapi\Scripts\alembic.exe__main__.py", line 7, in
File "c:\venvs\testapi\lib\site-packages\alembic\config.py", line 630, in main
CommandLine(prog=prog).main(argv=argv)
File "c:\venvs\testapi\lib\site-packages\alembic\config.py", line 624, in main
self.run_cmd(cfg, options)
File "c:\venvs\testapi\lib\site-packages\alembic\config.py", line 601, in run_cmd
fn(
File "c:\venvs\testapi\lib\site-packages\alembic\command.py", line 233, in revision
script_directory.run_env()
File "c:\venvs\testapi\lib\site-packages\alembic\script\base.py", line 578, in run_env
util.load_python_file(self.dir, "env.py")
File "c:\venvs\testapi\lib\site-packages\alembic\util\pyfiles.py", line 93, in load_python_file
module = load_module_py(module_id, path)
File "c:\venvs\testapi\lib\site-packages\alembic\util\pyfiles.py", line 109, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "C:\Users\USER\Desktop\fastapi-book-async\migrations\env.py", line 2, in
import models
File "C:\Users\USER\Desktop\fastapi-book-async.\models.py", line 4, in
from database import Base
File "C:\Users\USER\Desktop\fastapi-book-async.\database.py", line 38, in
SQLALCHEMY_DATABASE_URL_ASYNC = config('SQLALCHEMY_DATABASE_URL_ASYNC')
File "c:\venvs\testapi\lib\site-packages\starlette\config.py", line 100, in call
return self.get(key, cast, default)
File "c:\venvs\testapi\lib\site-packages\starlette\config.py", line 117, in get
raise KeyError(f"Config '{key}' is missing, and has no default.")
KeyError: "Config 'SQLALCHEMY_DATABASE_URL_ASYNC' is missing, and has no default."

alembic.ini 파일에 sqlalchemy.url = sqlite:///./testapi.db 설정도 해주고
env.py 파일에 import models, models.Base.metadata 설정해주었는데 왜 안될까요?

2084043 1028

2023년 9월 22일 12:31 오전

목록으로