Modified model.py to use a transaction

Each insert on the Raspberry Pi was taking up to 2 seconds. With a
couple hundred files this was taking over 90 seconds to update. Through
the use of a transaction this was dropped to around 6 seconds for the
same amount of files - about 16x faster than before.