[GNC-dev] Database abstraction

john jralls at ceridwen.us
Tue Aug 16 12:15:46 EDT 2022



> On Aug 16, 2022, at 4:54 AM, Thomas <tduellmann+gnucashdevel at gmail.com> wrote:
> 
> Hello everybody,
> 
> for quite some time I am interested in doing some simple queries against the data I have in my GnuCash books that I found hard to specify in custom reports or the like.
> As I have some technical background, I was thinking whether there is some DB abstraction that allows easier queries than the core database model behind GnuCash. At least for me, it would be easier to write some Python code or SQL queries rather than writing a custom GnuCash report tbh.
> 
> So a representation closer to the visual representation in GnuCash where it is easier (without countless JOINs for example) to make queries (e.g., get all transactions in a specific account that are higher than a certain amount).
> 
> I'd appreciate any kinds of hints on what you would use for such purposes!
> 
> Thanks a lot in advance!

For that specific example you could use the Python bindings to call xaccAccountGetSplitList() and filter the result by amount in a list comprehension. The API docs at https://code.gnucash.org/docs/MAINT are a good place to discover more functions like that. 

Regards,
John Ralls



More information about the gnucash-devel mailing list