How to pull and store data in external database

Hi, I would like to know how I can take and store data in an external database and import them into a doctype.
The external database is in postgresql, which is installed on a separate server.
Thanks everyone for a help

You can get the data in CSV format from postgreSQL and then import it into ERPNext using Data import templates.

Thanks for the reply
But what if I want to always use an external database for only some doctypes?
I would not use bench new-site --db-host myhost

Hi:

Take a look here:
https://frappeframework.com/docs/v14/user/en/basics/doctypes/virtual-doctype

Amazing sample with MongoDB

I think this is what you are looking for.
Hope this helps.