OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

CORS, SQLite and JavaScript. Any way to access the actual database without a local server?

  • Thread starter Thread starter Johnny Bigoode
  • Start date Start date
J

Johnny Bigoode

Guest
I just discovered the wonderful thing that SQLite is, and I'm trying to get it to work on a local HTML file without a server, just plain JavaScript.

The SQLite wiki states that the local database be 'get' via XMLHttpRequest

Code:
var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/database.sqlite', true);

But I can't because it's a cross origin requests. I had similar issues in the bast trying to read CSV files, and I solved it by using a file input and then passing the file forward to be parsed.

I tried doing the same thing, instead of passing /path/to/database.sqlite just passing the actual file. But it doesn't work.

Is there anyway to make this work without a local server and without messing with the security rules of the browser?

@YarGnawh like this C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --allow-access-from-files? I still get the same XMLHttpRequest cannot load file:///C:/BOVESPA2014.sqlite. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource.

<p>I just discovered the wonderful thing that SQLite is, and I'm trying to get it to work on a local HTML file without a server, just plain JavaScript.</p>
<p>The SQLite <a href="https://github.com/kripken/sql.js/wiki/Load-a-database-from-the-server" rel="nofollow noreferrer">wiki</a> states that the local database be 'get' via <code>XMLHttpRequest</code></p>
<pre><code>var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/database.sqlite', true);
</code></pre>
<p>But I can't because it's a cross origin requests. I had similar issues in the bast trying to read CSV files, and I solved it by using a file input and then passing the file forward to be parsed.</p>
<p>I tried doing the same thing, instead of passing <code>/path/to/database.sqlite</code> just passing the actual file. But it doesn't work.</p>
<p>Is there anyway to make this work without a local server and without messing with the security rules of the browser?</p>
<p>@YarGnawh like this <code>C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --allow-access-from-files</code>? I still get the same <code>XMLHttpRequest cannot load file:///C:/BOVESPA2014.sqlite. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource.</code></p>
 

Latest posts

Z
Replies
0
Views
1
zuegelwagen
Z
Top