def update_database(data): print('updating db') # start upload text if int(data['rows_saved']) > 0: if 'saved' in data: saved = data['saved'] if 'addresses' in saved: for addresses in saved['addresses']: address = Address() where = {'id': addresses['id']} data = {'address_id': addresses['address_id']} address.put(where=where, data=data) if 'colors' in saved: for colors in saved['colors']: color = Colored() where = {'id': colors['id']} data = {'color_id': colors['color_id']} color.put(where=where, data=data) if 'cards' in saved: for cards in saved['cards']: card = Card() where = {'id': cards['id']} data = {'card_id': cards['card_id']} card.put(where=where, data=data) if 'credits' in saved: for credit in saved['credits']: credits = Credit() where = {'id': credit['id']} data = {'credit_id': credit['credit_id']} credits.put(where=where, data=data) if 'companies' in saved: for companies in saved['companies']: company = Company() where = {'id': companies['id']} data = {'company_id': companies['company_id']} company.put(where=where, data=data) if 'custids' in saved: for custids in saved['custids']: custid = Custid() where = {'id': custids['id']} data = {'cust_id': custids['cust_id']} custid.put(where=where, data=data) if 'deliveries' in saved: for deliveries in saved['deliveries']: delivery = Delivery() where = {'id': deliveries['id']} data = {'delivery_id': deliveries['delivery_id']} delivery.put(where=where, data=data) if 'discounts' in saved: for discounts in saved['discounts']: discount = Discount() where = {'id': discounts['id']} data = {'discount_id': discounts['discount_id']} discount.put(where=where, data=data) if 'inventories' in saved: for inventories in saved['inventories']: inventory = Inventory() where = {'id': inventories['id']} data = {'inventory_id': inventories['inventory_id']} inventory.put(where=where, data=data) if 'inventory_items' in saved: for inventory_items in saved['inventory_items']: inventory_item = InventoryItem() where = {'id': inventory_items['id']} data = {'item_id': inventory_items['item_id']} inventory_item.put(where=where, data=data) if 'invoices' in saved: for invoices in saved['invoices']: invoice = Invoice() where = {'id': invoices['id']} data = {'invoice_id': invoices['invoice_id']} invoice.put(where=where, data=data) if 'invoice_items' in saved: for invoice_items in saved['invoice_items']: invoice_item = InvoiceItem() where = {'id': invoice_items['id']} data = {'invoice_items_id': invoice_items['invoice_items_id']} invoice_item.put(where=where, data=data) if 'memos' in saved: for memos in saved['memos']: memo = Memo() where = {'id': memos['id']} data = {'memo_id': memos['memo_id']} memo.put(where=where, data=data) if 'printers' in saved: for printers in saved['printers']: printer = Printer() where = {'id': printers['id']} data = {'printer_id': printers['printer_id']} printer.put(where=where, data=data) if 'profiles' in saved: for profiles in saved['profiles']: profile = Profile() where = {'id': profiles['id']} data = {'p_id': profiles['p_id']} profile.put(where=where, data=data) if 'reward_transactions' in saved: for reward_transactions in saved['reward_transactions']: reward_transaction = RewardTransaction() where = {'id': reward_transactions['id']} data = {'reward_id': reward_transactions['reward_id']} reward_transaction.put(where=where, data=data) if 'rewards' in saved: for rewards in saved['rewards']: reward = Reward() where = {'id': rewards['id']} data = {'reward_id': rewards['reward_id']} reward.put(where=where, data=data) if 'schedules' in saved: for schedules in saved['schedules']: schedule = Schedule() where = {'id': schedules['id']} data = {'schedule_id': schedules['schedule_id']} schedule.put(where=where, data=data) if 'taxes' in saved: for taxes in saved['taxes']: tax = Tax() where = {'id': taxes['id']} data = {'tax_id': taxes['tax_id']} tax.put(where=where, data=data) if 'transactions' in saved: for transactions in saved['transactions']: transaction = Transaction() where = {'id': transactions['id']} data = {'trans_id': transactions['trans_id']} transaction.put(where=where, data=data) if 'users' in saved: for users in saved['users']: user = User() where = {'id': users['id']} data = {'user_id': users['user_id']} user.put(where=where, data=data) if 'zipcodes' in saved: for zipcodes in saved['zipcodes']: zipcode = Zipcode() where = {'id': zipcodes['id']} data = {'zipcode_id': zipcodes['zipcode_id']} zipcode.put(where=where, data=data)