Created db module and get_latest_data function

correct (timestamp is a type in PostgreSQL and it's better to not use it)