synchronous python code that reads and inserts data in chucks