#1 2017-12-04 18:52:22

gothbert
Member
Registered: 2017-11-08
Posts: 12

Accessing legacy flat-file database from mORMot

Hi,

since 1990 I develop a specialized application based on a self-designed flat-file database in my spare time. With hundreds of databases being around and limited development time, a big bang migration to a modern backend (RMDBS) is not feasible. I therefore would like to use the mORMot framework and a custom backend to encapsulate access to the legacy database. Is this possible/advisable, and if so, could I please have some hints how to start?

The legacy flat-file database is a set of files in a folder with one file per entity and the position of the record in the file as ID. BTrees persistent in files are used to determine the sort order. The largest database is 120 MB, i.e. would nicely fit into memory/cache for queries. Delphi code already exists to read, modify, append, delete records and update the BTrees accordingly.

Kind regards
Boris

Offline

#2 2017-12-05 08:58:02

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

Re: Accessing legacy flat-file database from mORMot

Yes, this is perfectly feasible: the ORM could be extended to any kind of database.
You can define your own storage class for the mORMot TSQLRestServer instance, then assign a TSQLRecord to this storage.
Take a look at the TSQLRestStorage classes.

You could look at TSQLRestStorageInMemory, TSQLRestStorageExternal or TSQLRestStorageMongoDB classes, then implement your own class.
You need to add JSON serialization of the data to/from your engine (use the SynCommons classes for best performance), then override the Engine*() protected methods.
The only requirement is that you need an integer ID primary key, which seems to fit your data format.

After that, it will make no difference when you make queries on your data, from the ORM point of view.
It will even add simple SELECT statement parsing to your engine.

Offline

#3 2017-12-05 17:44:13

gothbert
Member
Registered: 2017-11-08
Posts: 12

Re: Accessing legacy flat-file database from mORMot

Great, thank you, Arnaud, for the fast reply and the advise with the steps to follow. Now I will have something to do during the holiday season :-)

Offline

Board footer

Powered by FluxBB