You are not logged in.
Pages: 1
i don't know whether or not the Httpserver can work as not only a Memorydb not but also holddiskDb?
there are some good uses.
1)Realtime data only process in Memory Db
2)historytime data saved in holddiskDB.
Sir, do you have some good ideas?
Offline
I don't think why you shouldn't use a regular database, and save its content to the disk.
But there is a possibility to store some tables only in memory, not in the main SQLite3 database file. I don't know if it's what you are looking for.
You just have to define a TSQLRecord child, then create a DB server (e.g. a TSQLRestServerDB instance), and call StaticDataCreate() method before the CreateMissingTables() method.
type
TSQLStaticData = class(TSQLRecord)
... define here a table, with properties to be kept in memory
end;
procedure DatabaseCreate;
begin
DB := TSQLRestServerDB.Create(DBModel,'filename.db3');
DB.StaticDataCreate(TSQLStaticData); // the TSQLStaticData table will be in memory
DB.CreateMissingTables;
HttpServer := TSQLite3HttpServer.Create('888',DB);
end;
When you quit the server application, all data contained in the TSQLStaticData table will be lost. But it could be accessible from any client application, like any other table.
Just a note about static tables: they just handle basic SQL statements, like "SELECT * FROM StaticData WHERE ID=23", not full qualified cross-table statements or such. But they are MUCH faster than the standard SQLite3 tables.
You can write the static tables content on disk, as JSON, if you specify a filename to the StaticDataCreate() method... but it's not perhaps what you need: in this case, you should better use a regular SQlite3 table.
Offline
ok,thanks a lot,
because my realtime table have about 20000 Records.i can use Update()* the static table , and In client use
INSERT INTO historytable select * from static table
at first.I worry about it will occupy pc resource, perhaps i should test httpserver's performace and ask question
Last edited by longge007 (2010-07-12 09:12:41)
Offline
if these 20000 rows of data is not meant to be saved on disk, it could be a solution to use StaticDataCreate. It depends on the data stored in it. About performances, handling 20000 rows is no problem for a static in memory engine.
You just have to guess how much memory it will use. If the data just contains text or numbers, I think your RAM will be big enough to handle it. Just guess the average size of every record, then multiply by 20000...
Offline
1. The insert command won't work: it will say to you an unknown table error, because statictable is not known by SQLite3 (it's internal to the framework)...
2. I'm sure it's not worth using such a memory copy then update the file on disk. SQlite3 is fast enough using regular access.
Offline
1. The insert command won't work: it will say to you an unknown table error, because statictable is not known by SQLite3 (it's internal to the framework)...
yeah, you are right, the Insert command don't work.
ok,i think i still use normal access to handle it.
thanks a lot
Offline
Pages: 1