|
|
楼主 |
发表于 2024-7-11 20:37:16
|
显示全部楼层
from app import db
6 O" s6 V j) B" X; Fdb.create_all()
! k) o, T1 }" ]+ ?) T! n0 MTraceback (most recent call last):2 E, C; j/ o" G) a C* c
File "C:\Program Files\JetBrains\PyCharm Community Edition 2023.2.1\plugins\python-ce\helpers\pydev\pydevconsole.py", line 364, in runcode* W$ {2 F! C$ v7 R! w z* [6 j$ y
coro = func()
! T) C' |5 b, g3 C. i ^^^^^^! E/ v( P7 e- v* i$ a
File "<input>", line 1, in <module>0 Z) a- [4 P* h/ r' V4 n
File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 900, in create_all* C9 X3 _% K3 n* T
self._call_for_binds(bind_key, "create_all")
6 Y9 X5 z( g$ l7 \2 Z' M" [" U" z+ { File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 871, in _call_for_binds: a/ D- `7 x: i! t+ i9 w4 d
engine = self.engines[key]6 m& {3 g- F4 q" Q! |
^^^^^^^^^^^^3 E* ~5 k, y' H! B$ j% d
File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 687, in engines
9 i" f2 A7 B- f3 v6 s# D app = current_app._get_current_object() # type: ignore[attr-defined]
5 J% }# C( @ K5 g- u ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^7 i* s) r3 Q# L3 C
File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\local.py", line 519, in _get_current_object
/ A6 ~6 b$ h0 o4 x! _ raise RuntimeError(unbound_message) from None
1 o$ y" C7 S3 f7 b0 ]) RRuntimeError: Working outside of application context.
4 r9 Z) Z' Q* q& n7 `This typically means that you attempted to use functionality that needed* h5 X- Y- ~: p. @" @
the current application. To solve this, set up an application context
1 s) L2 T7 e( v& L2 P8 wwith app.app_context(). See the documentation for more information.
5 ^- M" z% \$ c- H9 G+ n Z7 J |
|