#1 2013-01-29 14:41:08

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Newbie question. TSQLRecord and Database acess.

Hi,

I'm new with your ORM, while reading the SAD documentation. I don't understand how to get a TSQLRecord.CreateAndFillPrepare.

Connect to the database and use a TSQLDBStatement is all right.
But what class do I have to use to connect into the TSQLDBConnection and the TSQLRecord(if that is possible)?
How can I retrieve a record from the database to a TSQLRecord inherited class? Do I have to use TSQLRestServerDB?

Offline

#2 2013-01-29 16:28:00

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

Re: Newbie question. TSQLRecord and Database acess.

I you use the ORM part, do not use low-level SynSQLite3 nor SynDB classes and methods.
So here, forget about TSQLDBStatement / TSQLDBConnection, and use TSQLRestServerDB for a local server.

See sample 01 and 02 for instance...

Offline

#3 2013-01-29 16:41:56

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Re: Newbie question. TSQLRecord and Database acess.

OK, but how can I acess Fiberbird withou using TSQLDBStatement / TSQLDBConnection, and only using TSQLRestServerDB?

Offline

#4 2013-01-29 16:57:50

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

Re: Newbie question. TSQLRecord and Database acess.

You need a SQLite3 kernel, so TSQLRestServerDB is good, but you can leave your main database be ':memory:' so no SQLite3 file will be created.

Then you define all your tables as external, corresponding to your FireBird connection properties.

And you work with the ORM classes, just as usual.

Offline

#5 2013-01-29 17:12:08

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Re: Newbie question. TSQLRecord and Database acess.

Where in the SAD documentation can I find It? Is there any example for guide me?

Offline

#6 2013-01-29 18:52:29

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

Re: Newbie question. TSQLRecord and Database acess.

See "SQLite3/Samples/15 - External DB performance/PerfMain.pas" file.
For external DB.
You will get there some ideas, but it is a big complicated since it works with several external engines.

See http://synopse.info/fossil/artifact/eae … f66caad795 for a direct example of setting all tables as external.
It calls VirtualTableExternalRegisterAll() function.

Offline

#7 2013-01-29 22:39:31

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Re: Newbie question. TSQLRecord and Database acess.

I'm trying to emulate it, but some how doesn't work.

var
  Props: TSQLDBFirebirdConnectionClientProperties;
  Server : TSQLRestServerDB;
  Cli : TClient;
  CliModel : TSQLModel;
  Client : TSQLRestClientDB;
begin
  Props := TSQLDBFirebirdConnectionClientProperties.Create('localhost:X:\MORMOT\ORM\TEST.fdb', 'TEST.fdb', 'SYSDBA', 'masterkey');
  CliModel := TSQLModel.Create([TCliente], 'root');
  VirtualTableExternalRegister(CliModel, TClient, Props, 'CLIENT');
  Server := TSQLRestServerDB.Create(CliModel, 'application.db');
  Cli :=TClient.CreateAndFillPrepare(Server, 'ID=?', [1]);

It says theres no such table, but in the database the table is all normal. What am I doing wrong?

Last edited by TommyYommi (2013-01-29 22:41:50)

Offline

#8 2013-01-30 05:28:52

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

Re: Newbie question. TSQLRecord and Database acess.

You need to call CreateMissingTables method...

Offline

#9 2013-01-30 10:39:03

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Re: Newbie question. TSQLRecord and Database acess.

Ok, I add the code

Server.CreateMissingTables(0);

It says the table already exists.  What can be the cause of this error?

Last edited by TommyYommi (2013-01-30 10:40:26)

Offline

#10 2013-01-30 12:17:24

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

Re: Newbie question. TSQLRecord and Database acess.

Ensure you have the latest version from http://synopse.info/fossil

Some issues related to external table creation have been fixed.

Offline

#11 2013-01-30 12:58:14

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Re: Newbie question. TSQLRecord and Database acess.

I downloaded the last version, but the problem persist.

What does CreateMissingTables do?

On the Firebird database already exists a table CLIENT that I created and insert some records in it.I'm just trying to acess this Table and retrive one of those records.

Offline

#12 2013-01-30 13:21:45

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

Re: Newbie question. TSQLRecord and Database acess.

You are using TSQLDBFirebirdConnectionClientProperties direct access class, which is just not working, since it is not finished, but still a work in progress!
Statements even can not be executed with this unit...

To use an external FireBird database, you have to use the ODBC connector, until SynDBFirebird.pas is implemented.

Offline

#13 2013-01-30 14:04:12

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Re: Newbie question. TSQLRecord and Database acess.

Ok, do you think until June/2013 this unit will be work fine?

Offline

#14 2013-01-30 15:33:38

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

Re: Newbie question. TSQLRecord and Database acess.

I hope so!
It is a matter of weeks, from my understanding.
I would like to ship SynDBFirebird.pas with upcoming 1.18 release.

Offline

#15 2013-01-30 16:12:03

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Re: Newbie question. TSQLRecord and Database acess.

Perfect, I'm will wait for it.
It would very nice if you developed a example using this unit, when you release SynDBFirebird.pas.

What do you think? big_smile

Last edited by TommyYommi (2013-01-30 16:12:25)

Offline

#16 2013-01-30 16:17:29

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

Re: Newbie question. TSQLRecord and Database acess.

Yes, FireBird will be a first-class citizen within mORMot.

For instance, I would like to include it to SynDBExplorer tool.

Also, I would like to see SynDBfirebird included even within the regression tests, using the embedded version, if the dll is available within the main Delphi executable.

I'm wondering which kind of performance we may achieve.

Offline

Board footer

Powered by FluxBB