Is it possible to access the sqlite database with the help of javascript,if yes then can you please provide me a sample code please.
-
What is the context and what have you tried? – YXD Feb 27 '12 at 10:55
-
Is this javascript going to run in a web-browser, or on a server e.g. via node-js? – Andrew Skirrow Feb 27 '12 at 10:55
-
2mainly said NO, why ? because javascript runs on the client and not on the server. BUT javascript offers many ways to access php sites which provide sql functionality – mas-designs Feb 27 '12 at 10:57
-
1the thing, that i have to do is that its local on the client side i have to just fetch the values which are saved in my local database. – droid Feb 27 '12 at 11:07
2 Answers
Well, if you are working on client side JavaScript, I think you will be out of luck... browsers tend to sandbox the JavaScript environment so you don't have access to the machine in any kind of general capacity like accessing a database.
If you are talking about an SQLite DB on the server end accessed from the client end, you could set up an AJAX solution that invokes some server side code to access it.
If you are talking about Rhino or some other server side JavaScript, you should look into the host language's API access into SQLite (such as the JDBC for Rhino).
credit: SO Question: JavaScript sqlite
How to access the database using ajax and php ?

- 1
- 1

- 7,498
- 1
- 31
- 56
Why would you want to connect to a database with JS? Isn't it better to make an AJAX request and use PHP or another sever side language to connect to the database? it's better for security and doesn't slows the users pc down with scripts and connections, or at least not as much as handeling everything in js.

- 23
- 4