Gnucash reports using php and mysql

Donald Allen donaldcallen at gmail.com
Fri Dec 23 13:30:35 EST 2011


On Fri, Dec 23, 2011 at 12:53 PM, Pedro Abel <pedroabel at gmail.com> wrote:
> Hello developers,
>
> Donald, I followed your suggestion and read the thread "Scripting API" on
> the list archives. To be honest, it was kind of difficult to understand it,
> at least for me that do not know so much of programing yet. But despite
> that, I saw someone mentioning that there are Python bindings and you also
> mentioned that you used Python to create your own reports. Did you use
> those bindings for your script? Do you believe Python is a better a way to
> get custom reports?

I don't know PHP, so I'm in no position to offer an opinion about its
value as a programming language vs. Python. I do think Python is quite
good. Python programs tend to be concise and easy to read, a test of
whether the language designer has found something close to a minimal
"basis set". It's well documented, and it has a rich library from
which to draw. And Paul Graham loves it (if you've never read any of
his essays, I recommend them; here's one on Python:
http://www.paulgraham.com/pypar.html ; Graham is the person who said
that Perl programs look like "a cartoon character cursing", which
amused me greatly, because there's so much truth to it).

I did not use the Python bindings in my own report generator, because
they did not exist when I wrote it. If I were doing that work now, I
would certainly investigate this facility.

Have a good holiday!

/Don


>
> I saw also that many people creates custom scripts to get the reports
> according to each one needs. I would like to ask if you guys share those
> scripts somewhere in the internet? It will be nice to check this and maybe
> stop using php as I'm doing right now. I'm just using it because it seemed
> to me the easiest language to learn.
>
> Besides, as mentioned by Christian, I created a github with the php files.
> While I do not find a better way to do it, I will try to continue using php
> to get the reports I need:
> https://github.com/pedroabel/gnucashreports
>
> Thank you all and wish you all a nice Christmas.
>
> Best regards,
>
> Pedro
>
> On Wed, Dec 21, 2011 at 1:10 PM, Donald Allen <donaldcallen at gmail.com>wrote:
>
>> On Tue, Dec 20, 2011 at 5:11 PM, Pedro Abel <pedroabel at gmail.com> wrote:
>> > Hello friends, greetings from Brazil,
>> >
>> > My name is Pedro and this is the first time I send an e-mail to this
>> list.
>> >
>> > First, thank you all for such a great software. I'm using it for years.
>> >
>> > I was wondering if anyone is working on some reports for Gnucash not
>> using
>> > of the standard language (Scheme) Gnucash reports uses right now. I'm
>> > asking that because since there is the mysql option I started writing
>> some
>> > custom reports for my personal finances using PHP. Nothing really new,
>> just
>> > the same reports in a way that I prefer to see it (basically with each
>> > period organized into columns, for comparison, and with a quick way to
>> > group the values in broader periods, like quarters and years). The PHP
>> also
>> > allow me to check my reports quickly from any other computer in my
>> network.
>> >
>> > So, I would like to know if someone is doing the same, and maybe share
>> some
>> > codes.
>> >
>> > If you want, I could send to list what I have so far (does this list
>> > accepts attachments?). If so, please do not expect nothing exactly good,
>> as
>> > I'm not really a programmer. I'm just a regular user that wanted some
>> > custom reports and decided to do what I need instead of bothering you
>> with
>> > requests.
>> >
>> > Best regards,
>> >
>> > Pedro
>>
>> Pedro --
>>
>> A few years ago, I did something similar, though at the time, the
>> gnucash database option was not available. My motivation was the same
>> as yours -- I could not get what I wanted from the built-in reports
>> and I felt that the cost of trying to learn to work within gnucash (in
>> spite of the fact that I am a *very* experienced Scheme programmer)
>> was higher than the approach I took. I wrote a python program that
>> processes the gnucash xml file (the python library xml parser was very
>> useful for this). The program produces reports and charts by
>> generating latex and gnuplot files. It has served me well. While I now
>> do use the database capability (postgres), I have not yet taken the
>> time to convert my program to query the database rather than parsing
>> the xml file.
>>
>> Christian's response about using the C API makes sense to me if you
>> are modifying your gnucash data with an external program. Writing to
>> the database without using gnucash as an intermediary is a great way
>> to corrupt your data. But, if you restrict yourself to read-only
>> access to the data, then corruption is not an issue (I would still be
>> careful to back up your data in case you make an error and write to
>> the database accidentally -- unlikely, but possible). Then it becomes
>> a matter of which requires less effort on your part to get what you
>> want. I chose the same route you took on this basis. I'd suggest
>> having a look at an interesting thread, "Scripting API", on
>> gnucash-devel started by Hendrik Boom in November. It discusses
>> similar issues and the subject of the fairly new python bindings
>> capability comes up, something I have not investigated myself (only
>> because I already have something that serves my purpose, developed
>> before the python bindings capability became available) but is
>> probably worth looking at if you are actively developing reports for
>> yourself.
>>
>> /Don Allen
>>
>>
>> > _______________________________________________
>> > gnucash-devel mailing list
>> > gnucash-devel at gnucash.org
>> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>>
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel


More information about the gnucash-devel mailing list