找回密码
 注册
查看: 18|回复: 2

raise RuntimeError(unbound_message) from None RuntimeError: Working outside of a

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-7-11 20:29:54 | 显示全部楼层 |阅读模式
  raise RuntimeError(unbound_message) from None0 W9 a- I# ?" f* F! K( O
RuntimeError: Working outside of application context.
% ^$ F2 s3 e% a! Q% m' B: E3 mThis typically means that you attempted to use functionality that needed
! c! j: B. U5 K. @9 c
4 N/ H! [  N4 V$ u" W0 ]  N7 n+ h7 m

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-11 20:36:42 | 显示全部楼层
db.create_all() Traceback (most recent call last):

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:34 , Processed in 0.020163 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表