BQL PRINT command in a script

2021-04-15 Thread Daniele Nicolodi
Hello, I am writing a tool that should operate on a selection of entries from a Benacount ledger. I could come up with my own little DSL to do the selection, but we already have BQL, thus I think reusing it would be nice. To this extent, I was expecting to do simply something like: from beancoun

Re: BQL PRINT command in a script

2021-04-15 Thread Daniele Nicolodi
On 15/04/2021 15:31, Daniele Nicolodi wrote: > Hello, > > I am writing a tool that should operate on a selection of entries from a > Benacount ledger. I could come up with my own little DSL to do the > selection, but we already have BQL, thus I think reusing it would be nice. Replying to myself.

Re: BQL PRINT command in a script

2021-04-15 Thread Martin Blais
I would just write a loop against the API. shorter and more powerful.; On Thu, Apr 15, 2021 at 12:32 PM Daniele Nicolodi wrote: > On 15/04/2021 15:31, Daniele Nicolodi wrote: > > Hello, > > > > I am writing a tool that should operate on a selection of entries from a > > Benacount ledger. I coul

Re: BQL PRINT command in a script

2021-04-15 Thread Daniele Nicolodi
On 15/04/2021 20:27, Martin Blais wrote: > I would just write a loop against the API. > shorter and more powerful.; This does not look too bad already, but I have an hard time unpacking you suggestion. To which API are you referring to? Cheers, Dan -- You received this message because you are s

Re: BQL PRINT command in a script

2021-04-15 Thread Daniele Nicolodi
On 15/04/2021 20:55, Daniele Nicolodi wrote: > On 15/04/2021 20:27, Martin Blais wrote: >> I would just write a loop against the API. >> shorter and more powerful.; > > This does not look too bad already, but I have an hard time unpacking > you suggestion. To which API are you referring to? The w

Re: BQL PRINT command in a script

2021-04-15 Thread Martin Blais
entries, _, __ = loader.load_file(filename) for entry in data.filter_txns(entries): if : continue printer.print_entry(entry) On Thu, Apr 15, 2021 at 2:55 PM Daniele Nicolodi wrote: > On 15/04/2021 20:27, Martin Blais wrote: > > I would just write a loop against the API. > > shorter an

Re: BQL PRINT command in a script

2021-04-15 Thread Daniele Nicolodi
On 15/04/2021 23:27, Martin Blais wrote: > > entries, _, __ = loader.load_file(filename) > for entry in data.filter_txns(entries): >   if : >     continue >   printer.print_entry(entry) > My goal is to be able to do something like this: $ foobar.py ledger.beans --where="META('foo') = 'bar'" to

Re: BQL PRINT command in a script

2021-04-15 Thread Ben Blount
Why not write small python scripts whenever you want to do a query? You could have pre-written scripts with bindable parameters. You could even go as far as to accept python snippets from the command line, similarly to how petl does.

Re: BQL PRINT command in a script

2021-04-15 Thread Martin Blais
Oh wow, that's cool, I didn't realize it could do that on the cmdline. We'll build some Beancount helpers for petl. I love most things about petl. On Thu, Apr 15, 2021 at 6:51 PM Ben Blount wrote: > Why not write small python scripts whenever you want to do a query? You > could have pre-written