Skip to main content

Saving data permanently

Saving the database

When you refresh the web browser the database is by default not saved and thus it disappears. The command save saves the database so that all data and function definitions remain the next time you use SA Engine. The result of save is the name of the file where the database is saved.

Example:

save

The save command will save the current database in a database image file named sa.edge.dmp inside the bin folder of your SA home folder. You get the current SA home folder by evaluating:

sa_home()

You can list the files in your SA home bin folder by calling:

dir(sa_home()+"bin")

Inside the web browser the SA home folder is located in /home/web_user/SA/.

Note

In the free sandbox version of SA Engine the saved database image will disappear when the sandbox is restarted after 1-2 days. When the sandbox is restarted, it will use the factory database image instead.

If you run a downloaded system under Windows SA home folder is located in %USERPROFILE%\Documents\SA and the database will thus be saved persistently in the file %USERPROFILE%\Documents\SA\bin\sa.engine.dmp. Under OSX the folder is located in ~/Documents/SA and under Linux in ~/SA.

You can find the exact location and name of the current image file by calling the function:

image_file()

Restoring the factory database

You can erase the current database image and reset it to the original factory database by calling:

erase_image()

The function returns the name of the erased database image if it was found. When the browser is refreshed it will use the factory database image.

If you change your mind before the refresh you can restore the erased image by calling save.

Note

In the tutorial all data, the factory database also will be restored if you clear all user data in the browser.