Re: Reliability of small database system

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...

Thinking it over, I realized that it's possible to have the best of both worlds with sqlite. You can create the database, then dump it into a text file when you're done. Later, recreate the database from the text file for the next use and dump it into the original text file when finished. So you keep and use the text file (which is a script that contains human readable commands to recreate the database, tables, data, etc) as the location where data is saved instead of using a binary sqlite database file for this.

The text file will take up more space, so this isn't practical if your database is too large. Also, you lose some efficiency on loading/saving data. Still, if having stuff saved in human readable text is that important to you, or you believe that having human readable text is more reliable/less prone to corruption than the binary sqlite format (I honestly have no idea whether or not this is the case), then this might work out.

(To save time on loading, you could keep the binary sqlite file around too and just use it directly, but simply write out a new text file when saving data. Presumably, if it's corrupt, you simply won't be able to open it and can then recover data by recreating it from the text file. Likewise, for extra reliability, you could save off the old text files or archive them somewhere (instead of overwriting them) before dumping the database into a new text file.)

This method seems perfect. But we must take care that it is not like using a cannon to kill flies.

In my humble opinion, if you are using a small db, I'd better put your data in rows with text fields and manage these fields by a code euphoria.

You can instantly access the fields using matrices, as this example

constant DATE=1,VALUE=1,NAME=3  -- and so on 
dateSales = MyDbText[LineNumber][DATE] 
customerName = MyDbText[LineNumber][NAME] 
valueSales = MyDbText[LineNumber][VALUE] 

You can edit the data even using notepad.

Should do so with caution, it can cause a read error and euphoria will break your program.

I prefer an error euphoria, and I'm afraid of a crash of a database

I can fix an error using code euphoria, but do not know if it's the same with a database error.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu