Please Provide a Reader Only Release
Hi, I have a repository that requires to read data from SQLite. I'm pretty sure I need only to read data from without writing into it later. I understand 2.6MB is an ideal size but is it possible to provide a reader only release? Thx in advance.
Is your goal with a read only version to reduce the size of the javascript? Or protect the data being loaded?
@dinedal the former
You should issue PRAGMA query_only = true; as the first query after the database is loaded, and that will give you the behavior you desire.
https://www.sqlite.org/pragma.html#pragma_query_only
@dinedal perhaps we have some misunderstanding here: I don't control the sqlite file source at all. It will be provided by my users and I will need to read it and merge data. After that the sqlite file is left behind.
Right, you will need to read it, I presume using sql.js?
You will need to either issue an INSERT statements to insert the data, or you are reading the raw database.
I assume from your response that you're not doing the INSERT statements, and are reading the sqlite data directly? If so then you can open the database file, and then issue PRAGMA query_only = true;, and then do your SELECT to read the data out.
Or you are reading the rows in using INSERT statements, just insert the data and then issue PRAGMA query_only = true;, and then do your SELECT to read the data out.
If both are wrong, maybe you could be more specific on what you are loading and how?
I think this issue is about providing an sql.js file that would be smaller, but would lack the ability to alter the data in the database. The use-case is simple and (I believe) widespread: load a database file from a server and exploit its data on the client.
Unfortunately, sqlite itself does not seem to provide a compilation option for doing this. (https://www.sqlite.org/compile.html). So this feature being implemented is unlikely.
Ahhhhh yes damn when @Riajyuu replied 'the former' I totally flipped it around in my head! Sorry about that.
Yes, we don't have an easy way to do it in SQLite, we which this project is based off of.
@lovasoa is right. Except that I don't meet any server. Users must provide a sqlite location in file explorer. Once finished reading data, the sqlite file will be abandoned behind.
This page in the SQLite documentation might be of interest: https://www.sqlite.org/footprint.html
However, it mentions a reduction of only 3% of the binary size.
Other OMIT options from https://www.sqlite.org/compile.html may further reduce the binary size, but no SQLITE_OMIT_INSERT seem to exist.
I just about want to open new issue but I see my issue is already here. I just want to open file and read data and I think load nearly 2MB on web is a waste and on some where has low internet connection and that is a pain :) If you can support another lib like sql_read_only.min.js which is smaller size that would be nicer.
@bachvtuan As mentioned above, this library is based on a compilation of sqlite using emscripten. Since SQLite does not offer an option to create a read-only binary, sql.js is very unlikely to provide such an option anytime soon.
For those interested in a lighter alternative to sql.js, you can have a look at google's lovefield