How to execute `frappe.get_all` in ~/frappe-bench/xxx.py?

Hello everyone, how can I execute frappe.get_all in a python file not in the app folder? Is it able to connect to the database?