osqlite

1.1.2 • Public • Published

osqlite gives you an sqlite3 database on an object storage backed (like openstack swift).

Build Status Coverage Status Version License Code style Available platform

Motivation

Object storage is, by far, the cheapest cloud storage solution. If i want to store TB of contents, a CAS designed container is an excellent choice. But CAS relies on external database to handle file properties (name, directories & properties). osqlite allows you to store your database in the very same object storage container your CAS relies on.

osqlite uses the SQLite3 "hot" backup/replication API to publish current database and register triggers on the SQLite3 update hook API to know "when" to sync.

Usage example

const OSQLite = require('osqlite');

const creds   = require('./credentials');
const Context = require('swift/context');

var ctx = await Context.build(creds);
var lnk = OSQLite.build({
  backend   : {type : 'swift', ctx},
  container : 'container',
  filename  : 'index.sqlite',
});

await lnk.query("CREATE TABLE  IF NOT EXISTS lorem (info TEXT)");

console.log("Database contains %d entries", await lnk.value("SELECT COUNT(*) FROM lorem"));

for(let var i=0;i<10;i++) {
  let message = "foobar" + Date.now();
  console.log("Updating sqlite database");
  await lnk.insert("lorem", {"info": message});
  await sleep(200);
}


await lnk.close();//flush all to remote endpoint

Efficiency, triggers & throttle

osqlite will trigger synchronisation (object storage write) after each update/delete/insert following a cargo pattern.

Credits

Package Sidebar

Install

npm i osqlite

Weekly Downloads

0

Version

1.1.2

License

MIT

Unpacked Size

15 kB

Total Files

9

Last publish

Collaborators

  • 131
  • frodon