Skip to content

Please Provide a Reader Only Release #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Riajyuu opened this issue Nov 2, 2018 · 14 comments
Open

Please Provide a Reader Only Release #256

Riajyuu opened this issue Nov 2, 2018 · 14 comments

Comments

@Riajyuu
Copy link

Riajyuu commented Nov 2, 2018

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.

@dinedal
Copy link
Collaborator

dinedal commented Nov 2, 2018

Is your goal with a read only version to reduce the size of the javascript? Or protect the data being loaded?

@Riajyuu
Copy link
Author

Riajyuu commented Nov 2, 2018

@dinedal the former

@dinedal
Copy link
Collaborator

dinedal commented Nov 2, 2018

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 dinedal closed this as completed Nov 2, 2018
@Riajyuu
Copy link
Author

Riajyuu commented Nov 2, 2018

@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.

@dinedal
Copy link
Collaborator

dinedal commented Nov 5, 2018

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?

@lovasoa
Copy link
Member

lovasoa commented Nov 5, 2018

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.

@lovasoa
Copy link
Member

lovasoa commented Nov 5, 2018

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.

@dinedal
Copy link
Collaborator

dinedal commented Nov 5, 2018

Ahhhhh yes damn when @Riajyuu replied 'the former' I totally flipped it around in my head! Sorry about that.

@dinedal dinedal reopened this Nov 5, 2018
@dinedal
Copy link
Collaborator

dinedal commented Nov 5, 2018

Yes, we don't have an easy way to do it in SQLite, we which this project is based off of.

@Riajyuu
Copy link
Author

Riajyuu commented Nov 6, 2018

@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.

@lovasoa
Copy link
Member

lovasoa commented Nov 6, 2018

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.

@bachvtuan
Copy link

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.

@lovasoa
Copy link
Member

lovasoa commented Aug 5, 2019

@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.

@lovasoa
Copy link
Member

lovasoa commented Aug 23, 2019

For those interested in a lighter alternative to sql.js, you can have a look at google's lovefield

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants