小编loc*_*hok的帖子

Flask/Apache中的PyMySQL有时返回空结果

我有一个Flask应用程序,在Apache中运行,依赖于PyMySQL.该应用程序提供了一系列REST命令.它在Python 3下运行.

在不提供整个来源的情况下,该计划的结构如下:

#!flask/bin/python
import json
import pymysql
from flask import *

# Used to hopefully share the connection if the process isn't restarted
mysql_connection = None   

# Gets the mysql_connection, or opens it
GetStoreCnx():
    global mysql_connection
    if (mysql_connection != None):
        store_connection_string = ""
        # Get the connection string from the config file
        with open('config/storedb.json', 'r') as f:
            store_connection_string = json.load(f)
        mysql_connection = pymysql.connect(**store_connection_string)
    return mysql_connection;


class Server(Flask):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

# Return results via REST
@app.route('/results1', …
Run Code Online (Sandbox Code Playgroud)

python mysql apache flask pymysql

7
推荐指数
1
解决办法
625
查看次数

标签 统计

apache ×1

flask ×1

mysql ×1

pymysql ×1

python ×1