我想问为什么我的 create_engine 错误?我的端口是正确的,我在本地尝试过,从这里没有任何错误。但是,当我将它部署在我的 GCP 上时,它出现了这样的错误。我在本地使用 GCP 的 SQLAlchemy 版本具有相同的版本。
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.8/site-packages/uvicorn/workers.py", line 57, in init_process
super(UvicornWorker, self).init_process()
File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/main.py", line 20, in <module>
from db.session_car import SessionLocal as SessionLocalCar
File "/app/db/session_car.py", line 5, in <module>
engine = create_engine(settings.DATABASE_URL_CAR, pool_pre_ping=True)
File "<string>", line 2, in create_engine
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 298, in warned
有没有人有同样的错误我?
编辑:找到解决方案,降级 SQLAlchemy 版本。sqlalchemy_utils
当前与 SQLAlchemy > 1.4.0 不兼容