• database object

    From Ragnarok@VERT/DOCKSUD to DOVE-Net.Sync_JavaScript on Sun Apr 8 17:32:00 2007
    Hi peopleãi try to add a database support the the js script in syncrhonetãi use (at moment) sqlite as backend.ããi thinking in an object that may be used to easy storage data for door orãmodules and easy access via sql standard commands.ãan simple example of script code :ããdb = new Sqlite("/tmp/tu_base.db");ãdb.open();ãdb.stmt = "CREATE TABLE prueba (field1 int , field2 varchar(100))";ãdb.exec();ãdb.stmt = "INSERT INTO prueba (field1,field2) VALUES (10,'hola')";ãdb.exec();ãdb.stmt = "SELECT * FROM prueba";ãdb.exec();ãfor(i=; i< db.numRows; i++) {ã writeln (db.result[i]['field1'] + '-' + db.result[i]['field2']);ã}ãdb.close();ããim still working and not yet complete, also i dont know if will add to theãfutures sync versions.ããyou can see source code and example here:ãhttp://bbs.docksud.com.ar/~ragnarok/sync/js_sqlite/ããi wait for comments, suggest or wahtever for people that make js scripts.ããSaludos!ããã-- ãDock Sud BBSãhttp://bbs.docksud.com.arãtelnet://bbs.docksud.com.arãã---ã þ Synchronet þ Dock Sud BBS TLD 24 HS - www.docksud.com.arã
  • From Digital Man@VERT to Ragnarok on Mon Apr 9 15:38:41 2007
    Re: database objectã By: Ragnarok to DOVE-Net.Sync_JavaScript on Sun Apr 08 2007 05:32 pmãã > Hi peopleã > i try to add a database support the the js script in syncrhonetã > i use (at moment) sqlite as backend.ã > ã > i thinking in an object that may be used to easy storage data for door orã > modules and easy access via sql standard commands.ã > an simple example of script code :ã > ã > db = new Sqlite("/tmp/tu_base.db");ã > db.open();ã > db.stmt = "CREATE TABLE prueba (field1 int , field2 varchar(100))";ã > db.exec();ããWhy not just db.exec("CREATE TABLE prueba (field1 int , field2 varchar(100))")ã?ãã digital man (xbox-live: digitlman)ããSnapple "Real Fact" #161:ãThe first TV network kids show in the U.S. was "Captain Kangaroo." ãNorco, CA WX: 88.3øF, 31% humidity, 4 mph SSE wind, 0.00 inches rain/24hrsã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Ragnarok@VERT/DOCKSUD to Digital Man on Mon Apr 9 23:33:00 2007
    Digital Man wrote:ãã> Re: database objectã> By: Ragnarok to DOVE-Net.Sync_JavaScript on Sun Apr 08 2007 05:32 pmã> ã> > Hi peopleã> > i try to add a database support the the js script in syncrhonetã> > i use (at moment) sqlite as backend.ã> > ã> > i thinking in an object that may be used to easy storage data for doorã> > or modules and easy access via sql standard commands.ã> > an simple example of script code :ã> > ã> > db = new Sqlite("/tmp/tu_base.db");ã> > db.open();ã> > db.stmt = "CREATE TABLE prueba (field1 int , field2 varchar(100))";ã> > db.exec();ã> ã> Why not just db.exec("CREATE TABLE prueba (field1 int , field2ã> varchar(100))") ?ã> ã> ãnow, it work as exec(query) too.ããã-- ãDock Sud BBSãhttp://bbs.docksud.com.arãtelnet://bbs.docksud.com.arãã---ã þ Synchronet þ Dock Sud BBS TLD 24 HS - www.docksud.com.arã
  • From Tracker1@VERT/TRN to Ragnarok on Tue Apr 10 11:34:00 2007
    Ragnarok wrote:ã>>> db = new Sqlite("/tmp/tu_base.db");ã>>> db.open();ã>>> db.stmt = "CREATE TABLE prueba (field1 int , field2 varchar(100))";ã>>> db.exec();ã>>ã>> Why not just db.exec("CREATE TABLE prueba (field1 int , field2ã>> varchar(100))") ?ã> ã> now, it work as exec(query) too.ããSuggestion for syntax...ããvar db = new Sqlite("/tmp/tu_base.db");ãtry {ã db.open(); //throw an object when a connection fails...ã var results = db.exec("CREATE TABLE ...");ã //should return 0, no rows effectedãã results = db.query("SELECT ...");ã results.rows <-- array of rowsã results.columns <-- array of column titlesã for (i in results.rows) {ã results.rows[i]["columnName"]ã ...or...ã results.rows[i][columnIndex]ã }ã} catch(dbError) {ã console.write("ERROR: " + dbError.message + "\r\n\r\n");ã}ããJust a suggestion on this, to keep it easy enough to use the results...ãa .exec() method which executes the query and returns the rows affected as the ãresult... a .query() method which returns a results object that has a rows ãarray defined (each row containing an associative array for columns, in ãorder)... as well as a columns array listing the column names.. ãresults.rows.length could be used to determin a result count.ããHave a DatabaseErrorObject that is thrown when an error state occurs, with a ã.toString() and .Message properties for use in a result message.ãã-- ãMichael J. Ryan - tracker1(at)theroughnecks(dot)net - www.theroughnecks.netãicq: 4935386 - AIM/AOL: azTracker1 - Y!: azTracker1 - MSN/Win: (email)ãã---ã þ Synchronet þ theroughnecks.net - you know you want itã