sqlite use in tcl script over nfs (or.. how to make standalone sqlite3 which can be run over nfs)

StackOverflow https://stackoverflow.com/questions/2837528

  •  26-09-2019
  •  | 
  •  

Question

I want to use an embed an sqlite database into an existing tcl application (migrated from flat-file).

Currently; our tcl interpreter is run from a network location; <nfs share>/bin/tclsh8.3

I do have an nfs $PATH for executables set for all users already; I am assuming I can place a standalone sqlite3 executible there; though I have been not found an easy way to compile a local lib independent sqlite yet... (all linux clients, running anything from red hat 9 to ubuntu 10.04)

Anyone able to poke me in the right direction in building an sqlite3 standalone binary I can use in my nfs tcl install?

Was it helpful?

Solution

First off, Tcl 8.3.5 is ancient and relatively slow. Upgrading to 8.4 or 8.5 (if you can) will see performance improvements (exactly which is faster depends on what your script is doing).

Secondly, SQLite support is typically done through a loadable package (conventionally called sqlite3). You'll want to get a build that works with the oldest version of Tcl you're supporting (simply compiling in stubbed mode – I think that's default anyway – against the oldest Tcl version you want to support should be fine) and then put that in a directory (as a full install of the package) that you have on your code's auto_path. One of the nicest ways to do this is to get hold of a tclkit single-file-executable for Linux and to embed the sqlite3 package together with your in that; that's good because you can get everything together in one place so that users can't disrupt things easily by setting environment variables or other such nonsense. There is more help on doing this at https://stackoverflow.com/questions/1379577/…

Thirdly, mixing databases and NFS (or any other networked filesystem) is not recommended due to the difficulties with distributed locking and ensuring a proper flush to permanent storage during transaction COMMIT. Ensuring data integrity under those conditions is just plain difficult!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top