Using Customizer value in an external PHP file inside a theme

Coming back to this thread after five years as it’s still wasn’t marked as answered. Milo in the comments pointed out the answer: Trying to avoid including wp-load.php

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)