views:

7635

answers:

7
+7  Q: 

JavaScript sqlite

Best recommendations for accessing and manipulation of sqlite databases from JavaScript.

+1  A: 

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

Perhaps clarify your question a bit more...?

Mike Stone
"Perhaps clarify your question a bit more...?"You're absolutely right -- but then your encompassing answers clarifies for me, both my ignorance and the broadness of complete understanding. Thank you.
benphane
If I had indicated that my initial interest is with Firefox 3.xx sqlite data, I may not have received such a useful broad clarification.
benphane
+8  A: 

Google Gears has a built-in sqlite database - but you'll need to ensure that people have it installed if you plan to rely on it.

Depending on your circumstances, you may be able to enforce installation, otherwise you should treat it as a nice-to-have, but have graceful degradation so that the site still works if it isn't installed.

Cebjyre
+1  A: 

If you're running privileged scripts in Windows (either in an HTA or WSH), you can access ODBC data sources using an "ADODB.Recordset" ActiveXObject.

If you're talking about client side on a web page, the above post re: Google Gears is your best bet.

Joel Anair
+3  A: 

If you're looking to access SQLite databases on the browser (ie. client side) you'll need your browser to support it. You can do it with SpiderApe http://spiderape.sourceforge.net/plugins/sqlite/ which assumes that browser is Mozilla based (ie. with SQLite support). You'll still need to allow access to the underlying libraries ( http://www.mozilla.org/projects/security/components/signed-scripts.html )

If you're looking for serverside access from Javascript programs to SQLite databases there are several options: JSDB is one http://www.jsdb.org/ ; JSEXT another http://jsext.sourceforge.net/ ; and jslibs another http://code.google.com/p/jslibs/

-- MV

So many useful answers. Thanks. After posting here, I found http://developer.mozilla.org/en/Storage . I appreciate you helping me understand the scope of really understanding.
benphane
A: 

On a Mac? Take a look at Gus Meuller's JSTalk, which leverages Scripting Bridge and Patrick Geiller's JSCocoa.

Gus talks specifically about the Sqlite support here: http://gusmueller.com/blog/archives/2009/03/jstalk_extras.html ...works great.

jcburns
+2  A: 

Check out my video on YouTube . It covers programming Javascript/SQLite in a Webkit-based web browser (e.g. the browser in iPhone, Safari, Chrome).

Jay Godse
Was the video that bad? Or are you offended that I linked to a video that I happened to produce? Oy vey!
Jay Godse
A: 

You can perform it with XUL API on mozilla firefox stack. This some tutorial about it: http://www.arashkarimzadeh.com/articles/10-xul/25-sqlite-api-for-xul-application-using-javascript.html

brain90