-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
감사합니다. 그게 내가 찾고 있었던 것이었다. –