Untested, please report if it's useful! python-gnucash is a python binding to the GnuCash libraries. It uses SWIG and some additional python code to achieve this.