-2
我已經編寫了一個python腳本,用於從表中獲取特定數據並顯示數據。以下是腳本:python輸出不顯示在命令提示符上,但腳本正常工作
import MySQLdb
import os,sys
path="C:/Python27/"
conn = MySQLdb.connect (host = "localhost",user = "root", passwd = "cimis",db = "cimis")
c = conn.cursor()
station=[2,80,7]
date="8/1/2016"
hour=[200,300,400]
message = """select stationId,Date,hour,airTemperature from cimishourly where stationId in %s and Date=%s and hour in %s"""
c.execute(message,(station,date,hour))
result=c.fetchall()
for row in result:
print(row)
conn.commit()
c.close()
當我創建站ID列表時,它可以很好地顯示cmd上的所有輸出。但是,當我添加小時列表時,腳本運行時沒有錯誤,但在cmd上沒有看到輸出。 請幫我。謝謝
嘗試從這裏接受的答案:http://stackoverflow.com/questions/4574609/executing-select-where-in-using-mysqldb – nkhumphreys
謝謝。那正是我所期待的 –