データベースから常に日付を取得する次のコードがあり、現在の時刻がデータベースの時刻と等しいかどうかを確認します。言わずと知れた問題 オークション開始!それが想定されているように。
したがって、if文が正しくないと思います。誰かが正しい方向に私を助けることができますか? ありがとう!
def startAuctionServer():
global cursor
sql = ("SELECT Auction_StartDate closestDate FROM Auctions "
"WHERE DATE(Auction_StartDate) > '2012-10-09' "
"ORDER BY Auction_StartDate ASC LIMIT 1")
cursor.execute(sql)
results = cursor.fetchall()
for row in results:
auction_startdate = row[0]
print "AUCTION: %s" % auction_startdate
now = datetime.datetime.now()
print now.strftime("%Y-%m-%d %H:%M:%S")
if auction_startdate == now.strftime("%Y-%m-%d %H:%M:%S"):
# let the auctions begin
print "Auction begins!"
reactor.stop()
return
else:
reactor.callLater(0.05, startAuctionServer)
print "Auction Server Started"
reactor.callLater(0, startAuctionServer)
reactor.run()
解決した
私は自分が何をする必要があるかを理解しました。str を使用して値の文字列を作成し、それらを空白で分割しました。
if を次のように変更しました。
if str(now.strftime("%Y-%m-%d %H:%M:%S")).split() == str(auction_startdate).split()
今、私は自分がやっていることのベースを手に入れ、今では自分のプロジェクトに取り掛かることができます.
ありがとうございます!