How can I connect to a second database and still be able to use wp functions like get_post_types()?

How can I connect to a second database and still be able to use wp functions like get_post_types()?