https://github.com/131/osqlite
sqlite3 database on an object storage backed
https://github.com/131/osqlite
Last synced: about 1 year ago
JSON representation
sqlite3 database on an object storage backed
- Host: GitHub
- URL: https://github.com/131/osqlite
- Owner: 131
- License: mit
- Created: 2019-06-06T04:56:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-08T21:58:41.000Z (almost 7 years ago)
- Last Synced: 2025-04-21T12:44:28.617Z (about 1 year ago)
- Language: JavaScript
- Size: 33.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[osqlite](https://github.com/131/osqlite) gives you an [sqlite3](https://github.com/mapbox/node-sqlite3) database on an object storage backed (like [openstack swift](https://github.com/131/swift)).
[](https://travis-ci.org/131/osqlite)
[](https://coveralls.io/github/131/osqlite?branch=master)
[](https://www.npmjs.com/package/osqlite)
[](http://opensource.org/licenses/MIT)
[](https://www.npmjs.com/package/eslint-plugin-ivs)

# Motivation
Object storage is, by far, the cheapest cloud storage solution. If i want to store TB of contents, a [CAS designed](https://en.wikipedia.org/wiki/Content-addressable_storage) container is an excellent choice. But CAS relies on external database to handle file properties (name, directories & properties). [osqlite](https://github.com/131/osqlite) allows you to store your database in the very same object storage container your CAS relies on.
[osqlite](https://github.com/131/osqlite) uses the SQLite3 "hot" [backup/replication API](https://sqlite.org/backup.html) to publish current database and register triggers on the [SQLite3 update hook API](https://www.sqlite.org/c3ref/update_hook.html) 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](https://github.com/131/osqlite) will trigger synchronisation (object storage write) after each update/delete/insert following [a cargo pattern](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966).
# Credits
* [131](https://github.com/131)