|
|
@@ -4,6 +4,8 @@ from pprint import pprint
|
|
|
import time
|
|
|
import database
|
|
|
import sys
|
|
|
+import view
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
row = 0
|
|
|
@@ -48,8 +50,8 @@ if __name__ == '__main__':
|
|
|
db_data = cursor.fetchall()
|
|
|
|
|
|
# compare retrieved scratchings with new data
|
|
|
- match = False
|
|
|
for scratching in scratchings:
|
|
|
+ found_in_database = False
|
|
|
for row in db_data:
|
|
|
# print(row)
|
|
|
if (
|
|
|
@@ -62,19 +64,18 @@ if __name__ == '__main__':
|
|
|
scratching.venue,
|
|
|
scratching.race,
|
|
|
scratching.horse)
|
|
|
- print(message)
|
|
|
- match = True
|
|
|
- if not match:
|
|
|
+ # print(message)
|
|
|
+ found_in_database = True
|
|
|
+ if not found_in_database:
|
|
|
# report new scratching
|
|
|
message = 'New scratching: {} {} race {} horse {}'.format(scratching.date, scratching.venue,
|
|
|
scratching.race, scratching.horse)
|
|
|
- print(message)
|
|
|
+ view.broadcast(message)
|
|
|
# store new scratching
|
|
|
query = "INSERT INTO horses(venue, race_date, race, horse) VALUES(%s, %s, %s, %s)"
|
|
|
cursor.execute(query, (scratching.venue, scratching.date,
|
|
|
scratching.race, scratching.horse))
|
|
|
db.commit()
|
|
|
- match = False
|
|
|
cursor.close()
|
|
|
db.close()
|
|
|
|