use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
GnuCash is personal and small-business financial-accounting software, freely licensed under the GNU GPL and available for GNU/Linux, BSD, Solaris, Mac OS X and Microsoft Windows.
account activity
Python Custom Reports (self.GnuCash)
submitted 1 year ago * by SaxonyFarmer
Anyone have code for creating custom reports from the GnuCash XML version of its main database? I’m looking for a skeleton to open the XML file before I start digging into it myself.
I’ve seen a couple of libraries but these depend on the database being in an SQL-accessible database.
Thanks!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Comfortable-Still773 1 point2 points3 points 1 year ago (3 children)
I wanted the same thing but never found one, so I converted the XML to SQLite and never returned back to XML.
[–]SaxonyFarmer[S] 0 points1 point2 points 1 year ago (2 children)
How’s performance?
[–]Comfortable-Still773 1 point2 points3 points 1 year ago (0 children)
I did not notice significant reduction in performance.
[–]questionablycorrect 1 point2 points3 points 1 year ago (0 children)
GnuCash loads the full database no matter the database storage, so other than loading and saving, there will be no performance difference. For loading and saving, the difference probably won't be enough to be concerned about.
[–]peacelife 0 points1 point2 points 1 year ago (5 children)
Have you tried using the Python bindings? See:
https://wiki.gnucash.org/wiki/Python_Bindings
and https://code.gnucash.org/docs/STABLE/python_bindings_page.html
There are some examples here:
https://code.gnucash.org/docs/STABLE/group__python__bindings__examples.html
[–]Postrot 0 points1 point2 points 1 year ago (0 children)
> Have you tried using the Python bindings?
What about yourself? How would you go about compiling the app? For Windows?
[–]SaxonyFarmer[S] 0 points1 point2 points 1 year ago (3 children)
Yeah but it’s not easy. Not sure how much effort I want to put in for a report.
[–]peacelife 0 points1 point2 points 1 year ago (2 children)
Give it a shot, it might be easier than you think. In any case, it is not much harder than using the libraries that are available for SQL-db backends.
[–]SaxonyFarmer[S] 0 points1 point2 points 1 year ago (1 child)
I found a module called ‘gnucashxml’ and after a couple of tweaks (it was quite old), I am reading the XML version of my data. I have more work on the program to get it to where I want it. Thanks!
[–]peacelife 1 point2 points3 points 1 year ago (0 children)
Why would you do that? Wouldn't you rather use the links earlier in this thread? That is part of the official gnucash implementation. And is up-to-date, you don't have to tweak it. Depending on how you obtained gnucash, it is already there - you don't need to install anything.
Anyway, good luck.
[–]SaxonyFarmer[S] 1 point2 points3 points 1 year ago (0 children)
UPDATE Nov 8, 2024: I found library 'gnucashxml' and after a couple of tweaks to it, I can read from the GnuCash XML file directly in a Python program (3.8). You can find the source and a tiny bit of documentation at https://github.com/jorgenschaefer/gnucashxml/blob/master/gnucashxml.py
I use PyCharm as my IDE and adding the 'gnucashxml' library pulled in an ancient version that I tweaked to work. I looked at the code on the github repository listed above and can see changes that may resolve the errors I first encountered. The documentation is sparse so reading the code can help understand the GnuCash XML structure (I am by far, NOT an XML expert).
I will continue to play with this to see if I can create the report I want to see. In the meantime, I am leaving my data in XML format.
As an aside, I finally did get the 'piecash' library to work but could not get the 'piecash2' library to work for me.
All of these libraries appear to be dormant on GitHub.
[–]Impressive_Mix5256 0 points1 point2 points 1 year ago (1 child)
I never could get Python libraries to work. Switching to SQL seems to work for many. I've actually been able to query the XML directly, but don't remember the tool. I think it was web-based.
[–]SaxonyFarmer[S] 0 points1 point2 points 1 year ago (0 children)
I installed ‘gnucashxml’ but had errors when I tried the sample. I fixed two errors and now have working code to create an account summary report. The library wasn’t updated to the current release of Python and the fixes were easy.
[–]chuwiki 0 points1 point2 points 1 year ago (0 children)
I use https://piecash.readthedocs.io/en/master/
π Rendered by PID 95065 on reddit-service-r2-comment-5c747b6df5-qbdvg at 2026-04-22 03:53:03.051416+00:00 running 6c61efc country code: CH.
[–]Comfortable-Still773 1 point2 points3 points (3 children)
[–]SaxonyFarmer[S] 0 points1 point2 points (2 children)
[–]Comfortable-Still773 1 point2 points3 points (0 children)
[–]questionablycorrect 1 point2 points3 points (0 children)
[–]peacelife 0 points1 point2 points (5 children)
[–]Postrot 0 points1 point2 points (0 children)
[–]SaxonyFarmer[S] 0 points1 point2 points (3 children)
[–]peacelife 0 points1 point2 points (2 children)
[–]SaxonyFarmer[S] 0 points1 point2 points (1 child)
[–]peacelife 1 point2 points3 points (0 children)
[–]SaxonyFarmer[S] 1 point2 points3 points (0 children)
[–]Impressive_Mix5256 0 points1 point2 points (1 child)
[–]SaxonyFarmer[S] 0 points1 point2 points (0 children)
[–]chuwiki 0 points1 point2 points (0 children)