Sqlite in chrome

Is it possible to make a chrome extension that interacts with the sqlite database in the same way as the Firefox extension? Could you give me some advice or a link where there is more information about developing a chrome extension that interacts with sqlite?

Thank you

+55
javascript sqlite google-chrome-extension
Jun 01 '11 at 12:17
source share
4 answers

You can use the Web SQL API , which is a regular SQLite database in your browser, and you can open / modify it, like any other SQLite database, for example with Lita .

Chrome automatically finds databases according to domain names or extension ID. A few months ago, I posted a short article on my blog about how to delete a Chrome database , because when you test some features, it is very useful.

+24
Jun 23 2018-11-12T00:
source share
— -

You might be able to use sql.js.

sql.js is the SQLite port for JavaScript, by compiling SQLite C code using Emscripten. no C bundles or node -gyp compilation here.

<script src='js/sql.js'></script> <script> //Create the database var db = new SQL.Database(); // Run a query without reading the results db.run("CREATE TABLE test (col1, col2);"); // Insert two rows: (1,111) and (2,222) db.run("INSERT INTO test VALUES (?,?), (?,?)", [1,111,2,222]); // Prepare a statement var stmt = db.prepare("SELECT * FROM test WHERE col1 BETWEEN $start AND $end"); stmt.getAsObject({$start:1, $end:1}); // {col1:1, col2:111} // Bind new values stmt.bind({$start:1, $end:2}); while(stmt.step()) { // var row = stmt.getAsObject(); // [...] do something with the row of result } </script> 

sql.js is a single JavaScript file whose size is currently around 1.5MiB. Although this may be a problem on the web page, the size is probably valid for expansion.

+17
Nov 09 '14 at 2:45
source share

Chrome supports the WebDatabase API (which runs on sqlite), but it looks like the W3C stopped.

+12
Jun 01 2018-11-11T00:
source share

I'm not quite sure if you mean "can I use sqlite (websql) in chrome" or "can I use sqlite (websql) in chrome", so I will answer both:

Please note that WebSQL is not a full access channel in the .sqlite database. This is WebSQL. You will not be able to run some specific queries, for example VACUUM

This is awesome to create / read / update / delete. I made a small library that helps with all the annoying nitty gritty, such as creating tables and queries, and provides a small ORM / ActiveRecord template with relationships and everyone, as well as a huge stack of examples that should start you without delay, you can check it out here

Also, keep in mind that if you want to build a FireFox extension: Their extension format is about to change. Make sure you want to spend time twice.

While the WebSQL specification has been deprecated for many years, even now in 2017 it still doesn't look like it will be removed from Chrome in the foreseeable future. They track usage statistics, and in the real world there are still a large number of chrome extensions and websites that implement the specification .

+3
Feb 09 '17 at 20:54 on
source share



All Articles