Page 1 of 1

Moving an SQL database to LiveCode

Posted: Fri Jan 28, 2011 6:27 pm
by Simon Knight
Hi,

I run a small business and I control my time bookings, invoicing and expenses in an application I wrote in RealBasic. One of reasons I moved from Realbasic to RunRev was the lack of any simple report generation in Realbasic - when creating a report I have to keep track of where everything is on the page which makes updating my reports slow and error prone. The application, which is called Time&Expense uses an SQL database with 5 data tables to store company and client information. While SQL is powerful it is overkill for my small business and quite difficult to maintain. However one of the strengths of Time&Expense is that the data is completely separate from the application code and this feature allows the application to be updated while leaving the data intact.

When I port my application to Livecode I plan to use its built-in data storage capabilities rather than an external SQL database as my data tables are very small. I wish to maintain the data in a separate data file so that it is possible to simply perform data ups: this file could be either a TSV or similar file opened on start-up or possibly a sub-stack. I have searched the forum for advice and found the following:

Richard Gaskin wrote last October:
For documents, while I often use stack files for data storage because of the convenient efficiency of custom properties for storing stuff, I usually use it for storage only, with any views showing that data implemented as substacks of my app mainstack. This lets me update the user interface at any time without affecting the user's data files.

That's a whole other story we can get into later.
I am interested in how Richard's schema operates with a non-IDE version of the code, for instance is it a case of using a compiled/built main splash stack and having all the other stacks including those holding data as substacks thus allowing the subs stacks to be updated by the running application? If this is the way to go how would you advise implementing a 5 table structure; all the tables on one card, one table per card, one table per stack or some other cunning way?

Thanks for reading,
Simon

Re: Moving an SQL database to LiveCode

Posted: Fri Jan 28, 2011 6:46 pm
by BvG
No. that won't work. Substacks will be part of the Standalone executable, and therefore not saveable. what you want is just to use any stack file. Your standalone can load them, and use them afterwards as regular stacks. For example:

Code: Select all

on mouseUp --works in IDE as well as your standalone
  answer file "a stack"
  if it <> "" then
    go stack URL ("binfile:" & it)
  end if
end mouseUp
As for saving 5 tables, I'd suggest using custom properties. Using fields is sligthly slower, but has the advantage that Chars are automatically converted when going from windows to mac or back (you can do that yourself using the platform property and the isotomac() respectively mactoiso() functions. So it depends on your needs I guess.

Re: Moving an SQL database to LiveCode

Posted: Sat Jan 29, 2011 2:11 am
by FourthWorld
Simon Knight wrote:I am interested in how Richard's schema operates with a non-IDE version of the code, for instance is it a case of using a compiled/built main splash stack and having all the other stacks including those holding data as substacks thus allowing the subs stacks to be updated by the running application?
Saving data in LiveCode standalones
by Sarah Reichelt
http://livecodejournal.com/tutorials/sa ... ution.html

Re: Moving an SQL database to LiveCode

Posted: Sat Jan 29, 2011 11:30 am
by Simon Knight
Many thanks for the tips and links.

Simon