#1 2014-10-27 09:44:27

fabvit
Member
Registered: 2014-10-27
Posts: 9

Newbie questions

First of all let me say that I'm really impressed by the mormot framework.
I'm a RemObject/DataAbstract user and I'm seriously thinking to switch over mormot.

After having read the 1.8 documentation and done some lab experiment I've some newbie questions that I cannot find answer for.

Q1. External database access using AnyDAC still create a SQLite table
Using Firebird with AnyDAC I was able to create a simple project (I do not know how to upload to Synopse forums).

Why does mormot anyway creates a SQlite db, as in the following code  (// 5. Create a REST Client)?
I mean: does the creation of at least one SQlite db is mandatory *even* if you only use External database access?

procedure TMainForm.SetupDataBase;
var
  FirebirdServerIP: RawUTF8;
  FirebirdFDBFile: RawUTF8;
begin
  FirebirdServerIP := '127.0.0.1';
  FirebirdFDBFile  := 'C:\1DP\prove\mORMot_Test_Fabio\Data\MORMOT.FDB';

  DeleteFile(UTF8ToString(FirebirdFDBFile));

  // 0. Create an AnyDAC Physical DriverLink for Firebird (or drop a TADPhysIBDriverLink on the form)
  TADPhysIBDriverLink.Create(Application).VendorLib := 'fbclient.dll';

  // 1. Populate the AnyDAC/FireDAC Firebird ConnectionProperties
  fConnectionProps := TSQLDBFireDACConnectionProperties.Create('IB?CreateDatabase=Yes',
                                                               FirebirdServerIP + ':' + FirebirdFDBFile,
                                                               'SYSDBA','masterkey'
                                                              );

  // 2. Connecting has the side effect of creating the database file
  fConnectionProps.ThreadSafeConnection.Connect;

  // 3. Create the Model
  fModel := CreateModel;

  // 4. Register all external tables (*BEFORE* calling TSQLRestClientDB.Create!)
  VirtualTableExternalRegister(fModel, TSQLBaby, fConnectionProps, 'Baby');
  VirtualTableExternalRegister(fModel, TSQLParent, fConnectionProps, 'Parent');

  // 5. Create a REST Client
  fClient := TSQLRestClientDB.Create(fModel, nil, string('SQliteDb.sqlite'), TSQLRestServerDB, false, '');

  // 6. Create all missing tables/fields
  fClient.Server.CreateMissingTables;
end;

Q2. How to use mormot with DBAware controls like TEdit, TDBGrid etc?

Q3. How to transform my little sample project from a monolithic client-server to two distinct executables: client.exe and server.exe.

Can someone please help me, telling where can I upload my sample project in order to show you the code?

Thank you very much in advance.

--

fabio vitale

Offline

#2 2014-10-27 11:22:47

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

Re: Newbie questions

Q1. The main SQLite3 file is just to create some "virtual tables", which would be able to JOIN all model's table.
You can use SQLITE_MEMORY_DATABASE_NAME as database name if all your tables are external (e.g. via a VirtualTableExternalRegisterAll() call).

Q2. Either:
- Use some simple wrappers from objects;
- Our TDataSet as data source - see sample "17 - TClientDataset use".

Q3. Create two projects, then put your shared code in a single unit.
See all the client-server samples in the project.

Offline

#3 2014-10-27 12:26:59

fabvit
Member
Registered: 2014-10-27
Posts: 9

Re: Newbie questions

Arnaud merci mille :-)

I'll investigate and study as for your suggestions.

thank you!
--
fabio vitale

Offline

Board footer

Powered by FluxBB