In case that coffee machine loses connection during recording of a
coffee, this coffee is added once again as a part of offlineQueue.
Note: This commit implements a simpler solution suggested by Michal
Sojka and tested by Jiří Vlasák.
if time is None:
c.execute("insert into coffees (id, flavor) values (?,?)", (uid,flavor))
else:
- c.execute("insert into coffees (id, flavor, time) values (?,?,?)", (uid, flavor, time))
+ c.execute("insert or ignore into coffees (id, flavor, time) values (?,?,?)", (uid, flavor, time))
close_db(conn)
def flavors():
num integer primary key,
id varchar(24) references users(id), -- id may be unknown
flavor varchar(255) not null references flavors(name),
- time datetime default current_timestamp
+ time datetime default current_timestamp,
+ UNIQUE (id, flavor, datetime)
);