【发布时间】:2015-08-14 03:46:05
【问题描述】:
我有一个运行 Apache 的 ubuntu 服务器,我正在尝试连接到同一网络上的一个 sql 服务器。
当我在终端和import pymssqlandthen connect 中运行 python 时,连接没有问题,但是当我将相同的代码放入 init.py 时,它会在 conn=pymssql.connect 处停止运行线。有没有人对此有线索?
__init__.py
from flask import Flask, url_for, render_template
import pymssql
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, I love Digital Ocean!"
@app.route("/Reports")
def test():
conn=pymssql.connect(server='<fillinServer>', user='<fillinuser>', password='<fillinpassword>', database='<fillindatabase>')
print "1"
cursor=conn.cursor()
cursor.execute("SELECT TOP 1 * FROM testquery;")
print "2"
row=cursor.fetchone()
print "3"
t= row[1]
return render_template("test.html", test=t)
if __name__ == "__main__":
app.run(debug=True)
.WSGI
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/Reports/")
from ReportApp import app as application
application.secret_key = 'Add your secret key'
【问题讨论】:
-
日志中没有任何内容。内部错误 500。
-
其实重启apache后就是一直加载...
-
你发现问题了吗?我在这里遇到了确切的问题。
标签: python sql-server ubuntu flask pymssql