If at all possible, it's best to stay within the WordPress system when running WP, but if that's not possible then you would just need to initialize a connection with your database and handle it as normal.
Here is the PHP documentation for the Mysqli library, which is the new version of the depreciated Mysql library.