#1 2012-01-04 14:29:19

HSAR
Member
Registered: 2012-01-03
Posts: 3

Basic help

Okay, I'm just going to come out and admit this. I have no clue what I am doing, whatsoever.

Can somebody explain to me the basic steps that have to happen for me to use Database.Add to successfully add a record to a given table in a database? I am working off sample project number 2 ("Embedded SQLite ORM"), but am completely lost. I understand that a record is created and added to the database, but have no clue how the table to be added to is given, or (if I'm honest) even what is really going on here with Models and TSQLRecords or what on earth TSQLRest is and/or what it does.

I have been programming in Delphi for only about a year, so I'm really struggling to use this. Current Delphi version (that I'm using) is XE2, 32-bit (although through several attempts I have got all the dependencies and imports done without error).

Last edited by HSAR (2012-01-04 14:34:44)

Offline

#2 2012-01-04 15:05:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Basic help

Did you download the documentation?

All is explained in the SAD file.
It has more than 600 pages, but it's worth reading the first 130 pages (before the detailed per-unit description), which present all the underlining concepts, architecture and classes.

See http://synopse.info/fossil/wiki?name=Downloads

Offline

#3 2012-01-09 09:57:39

HSAR
Member
Registered: 2012-01-03
Posts: 3

Re: Basic help

I had a look at the documentation as you suggested, however am still in much the same state of confusion as before. Page 62 (1.4.1.8.3. Methods, not SQL) suggests that standard SQL statements are not used and replaced by handy methods that do much the same thing. It suggests that the CreateandFillPrepare method could (and should) be used in instead of a SELECT...FROM... SQL statement, but gives no reference as to how that might be used (or even where CreateandFillPrepare comes from).

At this point, I still have only just managed to be able to add some data to a database (largely by cannibalising code from sample project 2) and am trying to work out something as simple as the above SELECT...FROM... statement without success. I feel that there's something terribly vital that I have missed out.

Last edited by HSAR (2012-01-09 09:59:14)

Offline

#4 2012-01-09 10:43:01

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Re: Basic help

1. Entry point is here http://synopse.info/fossil/wiki?name=SQLite3+Framework.
2. This follows you to the download page.
3. Download and Read SAD documentation (ok, you already did)
4. Download official code at http://synopse.info/files/SynopseSQLite3.zip or bleeding edge code from the source control web interface (read about it here)
5. Look at examples in ...\Synopse\SQLite3\Samples\
6. Investigate the code (and comments in code) "playing" with examples or with your "samples"
7. Search first in this forum, because many questions was already asked, then ask...

Iterate all of the points again and again smile.


"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal

Offline

#5 2012-01-09 11:16:26

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Basic help

See next page (page 63) for sample code of how to use CreateandFillPrepare method.
Then use FillOne to loop through all the rows:

procedure TMyClient.FillDrives(aList: TStrings);
begin
  aList.BeginUpdate;
  try
    aList.Clear;
    with TSQLDrives.CreateAndFillPrepare(GlobalClient,'') do
    try
      while FillOne do
        aList.Add(UTF8ToString(Drive));
    finally
      Free;
    end;
  finally
    aList.EndUpdate;
  end;
end;

Then you'll have the reference documentation of this method on page 453.
Using the search feature of Acrobat Reader.
You'll find the same text in the SQLite3Commons.pas source. This reference documentation of all classes and declarations is in fact extracted from code comments.

I'll indeed need to add some sample code to the SAD documentation.
I understand your confusion - information is there, but not very pedagogical.

Offline

#6 2012-01-09 11:20:46

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Re: Basic help

Some suggestions from my personal experience:

1. It won't be easy trip if you want to use the framework "to the end"
2. As already told, framework is not RAD (forget quick designing) but SOA oriented (benefits come later). This is nice explained in SAD documentation.
3. For all-in-one applications with "tons" of GUI element, you rather stick with some RAD solution based on TDataSet. You have many (free and payable) out there, just search with google. You can do this kind of application with mORMot  too, but believe me, you will be slower. Except if you use mORMot user interface generation and that fits your needs. Mine has been totally different, so I have done it, all by myself (takes time). If you are using (and used to) some advanced grid, this you'll be missing most.
4. Think in objects, (almost) forget SQL. If you are used of tons of hand written SQL sentences you can used them in mORMot too, but this is not the right way and you are mixing two approaches often prematurely. Sometimes you must mixed them if you want some benefits from database (if you use only one type of persistence) which are not included in framework at same level.
5. For multi-tier or huge and complex applications the SOA way is the right way. So here the mORMot wins or better say it, is worth all effort invested it.


"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal

Offline

#7 2012-01-10 11:57:37

HSAR
Member
Registered: 2012-01-03
Posts: 3

Re: Basic help

Thanks for the suggestions and help.

I've decided that I'm going to change to another package for SQLite for now, and come back to mORMot when I have a project with less time pressure and more emphasis on performance.

Offline

Board footer

Powered by FluxBB