|
|
楼主 |
发表于 2024-7-11 20:37:16
|
显示全部楼层
from app import db
2 M* Y+ s! I$ Y; O' jdb.create_all()
& y" a) b8 c7 Q+ _5 BTraceback (most recent call last):
& J! ], |+ z0 L! @. f0 A File "C:\Program Files\JetBrains\PyCharm Community Edition 2023.2.1\plugins\python-ce\helpers\pydev\pydevconsole.py", line 364, in runcode
- K C4 |# o* V: u a coro = func()1 b( s3 K* Z( v( B P
^^^^^^! \$ I5 \( X1 Y. q5 @. r$ r' A* y) q
File "<input>", line 1, in <module>
* z7 A/ h' I. g8 A/ P/ g File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 900, in create_all8 {8 o, u3 T* i
self._call_for_binds(bind_key, "create_all")
0 i7 Z# n" f z, i+ O# t File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 871, in _call_for_binds
/ ^) c; F. p2 q) H engine = self.engines[key], h- G3 M0 n( Y2 W( Y
^^^^^^^^^^^^
7 ?0 ~; `" l: X File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 687, in engines
7 E4 n3 `1 W1 i! g app = current_app._get_current_object() # type: ignore[attr-defined]
/ V) Q' u+ j% @- Q8 C+ m. p! `' s ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^9 U( T) E# E Y4 g/ c& A
File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\local.py", line 519, in _get_current_object
. z f' l" _9 F8 W raise RuntimeError(unbound_message) from None
. T5 `7 b1 F6 X1 ?9 W- g/ _0 p9 RRuntimeError: Working outside of application context.
1 m5 }5 O/ _) z! n G8 uThis typically means that you attempted to use functionality that needed3 g" H; I- R% D( G, B
the current application. To solve this, set up an application context# `& m- B- P3 P Q
with app.app_context(). See the documentation for more information.! f. N% [7 ?0 `" k, V& `
|
|