293쪽 파이보 실행의 에러

AWS에 업로드하고 고정IP로 접속한 다음

회원가입 후 질문을 등록하려고 하면 다음과 같은 에러가 나옵니다. 왜 그런 겁니까?

sqlalchemy.exc.IntegrityError
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) NOT NULL constraint failed: question.user_id
[SQL: INSERT INTO question (subject, content, create_date, user_id) VALUES (?, ?, ?, ?)]
[parameters: ('테스트', '테스트', '2022-03-27 23:37:28.493589', None)]
(Background on this error at: https://sqlalche.me/e/14/gkpj)

Traceback (most recent call last)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1808, in _execute_context
self.dialect.do_execute(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
cursor.execute(statement, parameters)
The above exception was the direct cause of the following exception:
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask/app.py", line 2091, in call
return self.wsgi_app(environ, start_response)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask/app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(req.view_args)
File "/home/ubuntu/projects/myproject/pybo/views/auth_views.py", line 65, in wrapped_view
return view(
kwargs)
File "/home/ubuntu/projects/myproject/pybo/views/question_views.py", line 36, in create
db.session.commit()
File "", line 2, in commit

File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1431, in commit
self.transaction.commit(_to_root=self.future)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 829, in commit
self._prepare_impl()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 808, in _prepare_impl
self.session.flush()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3363, in flush
self._flush(objects)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3503, in _flush
transaction.rollback(_capture_exception=True)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 70, in exit
compat.raise
(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3463, in flush
flush_context.execute()
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute
rec.execute(self)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py", line 630, in execute
util.preloaded.orm_persistence.save_obj(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py", line 244, in save_obj
_emit_insert_statements(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py", line 1237, in _emit_insert_statements
result = connection._execute_20(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1620, in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
return connection._execute_clauseelement(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1487, in _execute_clauseelement
ret = self._execute_context(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1851, in _execute_context
self._handle_dbapi_exception(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2032, in _handle_dbapi_exception
util.raise
(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1808, in _execute_context
self.dialect.do_execute(
File "/home/ubuntu/venvs/myproject/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) NOT NULL constraint failed: question.user_id
[SQL: INSERT INTO question (subject, content, create_date, user_id) VALUES (?, ?, ?, ?)]
[parameters: ('테스트', '테스트', '2022-03-27 23:37:28.493589', None)]
(Background on this error at: https://sqlalche.me/e/14/gkpj)
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object
Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.

ivsinger 526

2022년 3월 27일 11:39 오후

목록으로
1개의 답변이 있습니다. 1 / 1 Page

저장할때 보면 user_id 값이 None이네요.
질문 등록하는 파이썬 파일을 함께 보여주시면 좋을것 같습니다.

박응용

2022년 3월 28일 8:20 오전