Desisti do mysqldb e estou usando o pymsql, agora o problema é diferente. Quando executo a função criar, o navegador me retorna um erro.
KeyError
KeyError: 'pymysql_kwargs'
Traceback (most recent call last)
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask\app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\pablo\PycharmProjects\jogoteca\jogoteca.py", line 57, in criar
def criar():
nome = request.form['nome']
categoria = request.form['categoria']
console = request.form['console']
jogo = Jogo(nome, categoria, console)
jogo_dao.salvar(jogo)
return redirect(url_for('index'))
@app.route('/login')
def login():
File "C:\Users\pablo\PycharmProjects\jogoteca\dao.py", line 16, in salvar
class JogoDao:
def __init__(self, db):
self.__db = db
def salvar(self, jogo):
cursor = self.__db.connection.cursor()
if (jogo.id):
cursor.execute(SQL_ATUALIZA_JOGO, (jogo.nome, jogo.categoria, jogo.console, jogo.id))
else:
cursor.execute(SQL_CRIA_JOGO, (jogo.nome, jogo.categoria, jogo.console))
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask_pymysql\__init__.py", line 48, in connection
ctx.mysql_db = self.connect
File "C:\Users\pablo\PycharmProjects\jogoteca\venv\lib\site-packages\flask_pymysql\__init__.py", line 28, in connect
if current_app.config['pymysql_kwargs']:
KeyError: 'pymysql_kwargs'
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