HELP: How to transfer data to/and from databases?

I am trying to insert data from database A to database B using code but I have no idea where to start. I also would want to use a filter such as tags or other. Please help in any way!

Thanks in advance!