[GNC] I'm still a bit confused about when things get saved.

Derek Atkins derek at ihtfp.com
Thu Sep 10 08:58:04 EDT 2020


Hi,

On Thu, September 10, 2020 8:32 am, Chris Green wrote:
>
> When does data entered get saved?  Also are there different 'levels'
> of save as it were?

Yes, there are different levels of data storage, per se.  There are:

* Data Entry -- the data only lives in the UI
* Commit -- the data is stored into the in-memory cache of your data
* Save -- the in-memory cache is written to disk

> It seems to be as follows but I'd like to be sure (*and* I'd like to be
> able to change things somewhat) :-
>
>     While entering values (including date, description etc. as well as
>     the actual amounts) the data isn't saved anywhere.  If you leave
>     the transaction you're editing without hitting the +Enter button
>     then the data doesn't get anywhere useful.  *But* the data isn't
>     lost, it's still there if you go away to another account and then
>     back.

Correct.  You have to actually commit the transaction for the changes to
be, well, committed.  This is considered a FEATURE that it is not
committed until you are ready to do so.  Sometimes you might need to visit
a different register to validate some data.  So yes, you must commit the
transaction explicitly.

>     When you hit +Enter the transaction gets 'added to the accounts'
>     and totals, balances, etc. will be updated with the new transaction.
>     What isn't clear is whether this also stores the new transaction
>     to file.

Correct, this is "commiting" the transaction.  At this stage it will only
go into the in-memory cache of your data.  It is not written to disk
(unless you're using a SQL backend -- that's one of the two main
differences between SQL and XML-File storage).

>     Whenever I leave GnuCash I get the Save warning (unless I've just
>     done a Save) saying that everything will be lost.  This appears to
>     always be everything since I started a new session, not just the
>     last transaction.  So does GnuCash have an 'in memory' (or at
>     least not in the normal saved file) copy of the accounts that is
>     only saved when you explicitly do a 'Save'?

Yes.  If you are using the XML-File backend (the default) then you must
explicitly dave the data for it to get stored to disk.  There is an
autosave feature that will automatically save your data every (30?)
minutes (I don't recall the default setting).

If you use the SQL backend then your commits are saved to storage
immediately as explained above.  HOWEVER, the other main difference is
that with the File-XML backend you get an explicit backup file created
every time you save, but with SQL, there is NO backup file -- you are
expected to make frequent backups of your database.  This is particularly
important as GnuCash has no "undo" function.

> Are my above guesses about when data is saved correct?  Does one
> *always* have to hit +Enter or are there implicit ways of doing it?
> I'd really prefer transactions to get stored when I move move away to
> another account rather than having to hit +Enter.

There are other ways to do it other than hitting "Enter".  Specifically,
any time you leave the transaction *in the same register* it will
implicitly commit it.  But you must physically (well, visually) change to
a ddiferent transaction *IN THE SAME REGISTER*.  I.e., you must manually
exit the transaction.  You can do this by the up/down arrows, tabbing out,
or hitting Enter.  But exiting the register is not sufficient.

>   Can GnuCash be configured for more 'automatic' storing of entered data?

Yes, there is the autosave feature mentioned abocve, or you can change to
a SQL backend (with the caveat that you need to manually back up your data
frequently).

> Many/most applications seem to save data automatically by default,
> i.e. the data gets saved to file/disk as you move from field to field.

Um, I don't think so.  Havent you ever lost work in Word/Excel/Powerpoint
(or their LibreOffice counterparts)?  I know I have!  Indeed, MOST
applications require a manual save, or have a periodic (but not
instantaneous) auto-save.  A save-as-you-go is VERY expensive, especially
when a save means serializing the whole dataset into a file and writing it
to disk -- with lots of data that can take several seconds at a pop.  Many
(most!) people wouldn't want their session to freeze for 10 seconds every
time they enter a transaction!

I am not saying that there isn't room for improvement, but we got to where
we are today over multiple decades of back and forth to ensure the "best"
of all worlds, but with tweaks to make everyone happy.  Feel free to set
your autosave to 1 minute if that's what you want.  If you haven't made
any change then it won't do anything, but it does mean your app will
freeze a lot as it saves in the "background".

Hope this helps,

> Chris Green

> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.

-derek

-- 
       Derek Atkins                 617-623-3745
       derek at ihtfp.com             www.ihtfp.com
       Computer and Internet Security Consultant



More information about the gnucash-user mailing list