« Previous | Next »

UnQLite Jx9 Part II

10 Jul 2015

Masashi Umezawa graciously granted me write-access to the PunQLite wrapper repository. (Thanks, Masashi!) I've now added functionality to set Jx9 variables from Smalltalk.

Here's an example. The variable $inject is to be set from Smalltalk.

if (db_exists("users")) {
  db_drop_collection("users");
}
db_create("users");
db_store("users", $inject); 
$extract = db_fetch("users");

Here's the Smalltalk code:

| j db inject extract |

j := '...'. "Above Jx9 program."

db := PqDatabase openOnMemory.
[   db jx9Do: [ :exe |
        exe compile: j.
        inject := exe newStructure: 'inject'.
        inject at: 'name' put: 'Jim'.
        inject at: 'age' put: 29.
        exe inject: inject.
        exe release: inject.
        exe execute.
        extract := exe @ 'extract'.
        Transcript show: extract isJsonObject asString; cr.
        exe release: extract ]
] ensure: [ db close ]

Transcript should show "true". Round-trip set/get tests between Pharo and the Python wrapper by Charles Leifer were successful.

I added an assert-filled version of the above code as a unit test. Running the test by itself succeeds. Running it from Test Runner fails...

I won't go figure, though. I don't intend to spend any more time on Jx9. Using Jx9 with Smalltalk effectively requires managing Jx9 source as strings within Pharo. I might as well stick with SQLite and SQL strings in that case. If I must have key-value stores I can always use 2-column tables.

The Python wrapper carries this note: "The authors of UnQLite, Symisc, have informed me that UnQLite is no longer being developed actively."

Tags: NoSQL