sqlite use from max-JS
Hello,
I'm wondering how far in Max8.3 one can use the embed sqlite thru max JS. I encouter several issues when trying to use it :
- the sqlite's old doc seems to be obsolete since the method 'open' makes Max8 crash as soon as it mentions the ram-based optional boolean arg ;
-after opening a file.db (with no error nor warning) , exec a statement such as "SELECT * FROM table;" returns the error: "sqlite_exec: 1 (no such table: atable)" - even if writing the full path "Macintosh HD:/Users/me/path/to/data.db" ;
- the example in the (old) tutorial using "sqlite.getversion()" tells that sqlite.getversion is not a function ;
- and the statement sqlite.exec("SELECT sqlite_version() AS version;", res) returns an empty JS object with no error nor warning.
If older posts in the Forum mention these issues here and there, they still have no answer (see my previous post today).
I experienced that [node.script] object makes sqlite3 working, but I would prefer, if possible, to use only Max own ressources and use Max-JS instead of node.js.
Anyone have a recent experience with ?
Bests.
Yes this tutorial is out of date and has some incorrect information.
The biggest issue I'm seeing is that it is no longer possible to open a database file, if that database doesn't already exist. The workaround would be to create an empty file, and then pass that file path to the database open message. You can easily do this with the "write" message to an empty text object.
The other issue is the tutorial uses a relative path for the database file, and I'm not sure if that ever worked. The fix here is to pass absolute paths (or supported Max paths like Desktop:/mydbfile).
(and yes, getversion is not a supported message)
We'll ticket these issues, but I would proceed with the workarounds for now. Fortunately, it looks like the rest of the database functionality is still working as expected.
here's the modified tutorial patch (use with the existing tutorial JS file)
Thank's Rob for your help which makes my patch to work.
In effect, it seems that there is an issue with the form of the pathname, which could make Max crash if not in the good form and if the ram-based arg of open method is 1 or 0 (but no crash if no ram-based arg).
Cheers.