Access database functions in external script

This should help (see the third post): How to Load Data from Database into Custom Files (v2025)