crmfghtr wrote:
he code below is inserting records from the Main database inventory table, and not from the backup database
It is because you don't mention in your SQL query from/to what database you select/insert the data. See [sql - How to insert table values from one database to another database? - Stack Overflow](https://stackoverflow.com/questions/3502269/how-to-insert-table-values-from-one-database-to-another-database)