CiviCRM Membership data to external Database
You should always use the API and only if there is no other route grab the SQL table. You do not need to connect to any CiviCRM database when using the API.
You can find more information on the API in the Developer Guide: https://docs.civicrm.org/dev/en/latest/api/

Do I understand correctly that you want to send data to your other application when a membership is created in CiviCRM? If this is the case you should develop a CiviCRM extension using the post hook. You can find more information on developing an extension in the Developer Guide: https://docs.civicrm.org/dev/en/latest/extensions/ and also on the post hook: https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/.

The post hook will allow you to retrieve all the membership data from the $objectRef object when you catch an $objectName Membership and $op create (or probably edit as well when a membership changes?).

Alternatively you can pull data from CiviCRM using the API if synchronizing every hour/day is enough?