Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to load SQLite database from TStream?


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Jul 25, 2017 1:30 PM Last Post By: Stanislav Ermolov
Stanislav Ermolov

Posts: 3
Registered: 5/25/15
How to load SQLite database from TStream?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 25, 2017 7:38 AM
Hi!
I'm using Delphi XE and load local SQLite file with FireDac:

ADConnection1.Close;
ADConnection1.Params.Clear;
ADConnection1.Params.Add('DriverID=SQLite');
ADConnection1.Params.Add('Database=C:\My_db');
ADConnection1.Open;
ADConnection1.GetTableNames('', '', '', ListBox1.Items);

It works fine.

But I need to use TMemoryStream instead of file ('C:\My_db').
How can I load DB from Stream?

P.S. I can't save my Stream to file! I have to load DB right from Stream.
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: How to load SQLite database from TStream?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 25, 2017 11:57 AM   in response to: Stanislav Ermolov in response to: Stanislav Ermolov
Stanislav Ermolov wrote:
Hi!
I'm using Delphi XE and load local SQLite file with FireDac:

ADConnection1.Close;
ADConnection1.Params.Clear;
ADConnection1.Params.Add('DriverID=SQLite');
ADConnection1.Params.Add('Database=C:\My_db');
ADConnection1.Open;
ADConnection1.GetTableNames('', '', '', ListBox1.Items);

It works fine.

But I need to use TMemoryStream instead of file ('C:\My_db').
How can I load DB from Stream?

P.S. I can't save my Stream to file! I have to load DB right from Stream.

You aren't loading a SQLite file into your app, you are telling the SQLite
server where the file is for it to respond to queries etc.

I highly doubt the SQLite server can work from a memory stream as the source of
the data.

Now FireDAC does have an in memory table component (TFDMemTable) that can load
its data from a stream, but it has to be in a format that the component
understands, not a SQLite table as a stream.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

Stanislav Ermolov

Posts: 3
Registered: 5/25/15
Re: How to load SQLite database from TStream?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 25, 2017 12:28 PM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Now I'm doing it with interception functions of "Kernel32.dll" (CreateFileW, SetFilePointer, ReadFile, ...)
It works. But not always :)
So I'm looking for another ways...
Stanislav Ermolov

Posts: 3
Registered: 5/25/15
Re: How to load SQLite database from TStream?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 25, 2017 12:21 PM   in response to: Stanislav Ermolov in response to: Stanislav Ermolov
Thanks for reply.

I'm working with deleted files. I restore them. In this situation I have to analyze this database before restoration. So I have the file content only in memory... And I can't save it to HDD.
I have idea to learn the SQLite file structure, read it manually and add to FireDAC. But it's very long way...
So I hope for another solution.

Any components (not FireDAC only) are welcome.

Edited by: Stanislav Ermolov on Jul 25, 2017 1:30 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02