293페이지 테스트 데이터 만들기
AWS에 개발한 내용을 업로드 후에
DB에 문제가 있어서 초기화 이후에
123p에서 배운대로 테스트 데이터 300개를 추가 하려고 하는데
아래 for문 실행시 문제가 발생합니다.
혹시 이유와 대응 방법을 알 수 있을까요?
>>> from pybo import db
>>> from pybo.models import Question
>>> from datetime import datetime
>>> for i in range(300):
... q = Question(subject='테스트 데이터입니다:[%03d]' % i, content='내용무', create_dat
e=datetime.now())
... db.session.add(q)
...
Traceback (most recent call last):
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/util/_collecti
ons.py", line 1008, in __call__
return self.registry[key]
KeyError: <greenlet.greenlet object at 0x7fce0241dd50 (otid=0x7fce03386040) current active
started main>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<string>", line 2, in add
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/scoping.py
", line 24, in _proxied
return self.registry()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/util/_collecti
ons.py", line 1010, in __call__
return self.registry.setdefault(key, self.createfunc())
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/session.py
", line 4205, in __call__
return self.class_(**local_kw)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask_sqlalchemy/__init__
.py", line 174, in __init__
self.app = app = db.get_app()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask_sqlalchemy/__init__
.py", line 1042, in get_app
raise RuntimeError(
RuntimeError: No application found. Either work inside a view function or push an applicat
ion context. See http://flask-sqlalchemy.pocoo.org/contexts/.
>>> db.session.commit()
Traceback (most recent call last):
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/util/_collecti
ons.py", line 1008, in __call__
return self.registry[key]
KeyError: <greenlet.greenlet object at 0x7fce0241dd50 (otid=0x7fce03386040) current active
started main>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 2, in commit
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/scoping.py
", line 24, in _proxied
return self.registry()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/util/_collecti
ons.py", line 1010, in __call__
return self.registry.setdefault(key, self.createfunc())
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/session.py
", line 4205, in __call__
return self.class_(**local_kw)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask_sqlalchemy/__init__
.py", line 174, in __init__
self.app = app = db.get_app()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask_sqlalchemy/__init__
.py", line 1042, in get_app
raise RuntimeError(
RuntimeError: No application found. Either work inside a view function or push an applicat
ion context. See http://flask-sqlalchemy.pocoo.org/contexts/.
ivsinger 님 366
M 2022년 3월 29일 6:13 오후