
どのようにデータベースに問い合わせているの?
log_request
関数では、
insert
文を使ってリクエストの情報をデータベースに追加
しています。
log_request
を呼び出すと、
cursor.execute
が
insert
を実行して
いる間は待たされることになります。
def log_request(req: 'flask_request', res: str) -> None:
with UseDatabase(app.config['dbconfig']) as cursor:
_SQL = """insert into log
(phrase, letters, ip, browser_string, results)
values
(%s, %s, %s, %s, %s
)"""
cursor.execute(_SQL, (req.form['phrase'],
req.form['letters'],
req.remote_addr,
req.user_agent.browser,
res, ))
view_the_log
関数でも同じです。
select
文を実行するたびに待たされることにな
ります。
@app.route('/viewlog')
@check_logged_in
def view_the_log() -> 'html':
try:
with UseDatabase(app.config['dbc
onfig']) as cursor:
_SQL = """select ...