Skip to content

jalcine/sqlite-hypercore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLite and Hypercore

Build Status

A Rust library providing SQLite with an virtual file system to enable Hypercore as a means of storage.

Contributing

The primary repository for this project is stored at git.jacky.wtf and mirrored to github.com. You can use whichever code forge you'd prefer.

It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies, including this one.

Things to Do

  • Complete the wrapper over sqlite3_vfs in sqlite_hypercore::vfs.
  • Implement individual database lookups by petnames into Hypercore in sqlite_hypercore::vfs::hyper.
  • Ensure multi-thread support.
  • Add tests.
  • (Eventually) upstream the VFS wrapper logic to rusqlite.
  • Figure out how to handle peering of the Hypercore backend.
  • Support opening remote databases using a URL, i.e.: hyper://$HOST/path?vfs=$HYPERCORE_VFS_NAME
  • ... and local ones i.e.: hyper:path?vfs=$HYPERCORE_VFS_NAME or hyper:///full/path?vfs=$HYPERCORE_VFS_NAME.

End Goal

The final result is to be able to open up a connection to a Hypercore daemon on a local (or remote machine), find a database that can be written to and continue to work with SQLite as if it were a regular instance on the local machine.

use rusqlite::{Connection, OpenFlags};
use hypersqlite::{Instance, Vfs, VfsOptions, Storage};

#[async_std::main]
async fn main() -> anyhow::Result<()> {
  let mut hyper_vfs_options = VfsOptions::default();
  hyper_vfs_options.storage = Storage::InMemory;

  let hyper_vfs = Vfs::connect(hyper_vfs_options)
    .expect("Failed to connect to Hypercore daemon.");

  let inst = Instance::register("hyper-memory", hyper_vfs, false);

  let conn = Connection::open_with_flags("docs.db",
    OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE,
    inst.deref().borrow().vfs_name()?
    );

  // The database's been written into memory but into the Hypercore!
  Ok(())
}

Licensing

This project is dual-licensed under the BSD 2 and MIT. Just don't use it for things like ICE or the like!

About

Provides a Rust-based SQLite extension for using Hypercore as the VFS for your databases.

Resources

License

BSD-2-Clause, MIT licenses found

Licenses found

BSD-2-Clause
LICENSE.BSD-2
MIT
LICENSE.MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published