Last active
December 17, 2015 06:09
-
-
Save YCF/5563469 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/', methods=['GET', 'POST']) | |
def demo(): | |
conn=pymssql.connect(host='blablabla\SQLEXPRESS',user='blabla',password='123',database='x',charset='utf8') | |
cur=conn.cursor() | |
sqlquery=u"SELECT TOP 1000 [ID],[姓名],[内容] FROM demo_db" | |
sqlquery=sqlquery.encode("utf8") | |
cur.execute(sqlquery) | |
row=cur.fetchone() | |
cts = [dict(name=row[1],ct=row[2]) for row in cur.fetchall()] | |
for i in cts: | |
i['name']=i['name'].decode('utf8') | |
conn.close() | |
return render_template('demo.html',cts=cts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment