项目作者: sqlite-js

项目描述 :
An experimental SQLite library for Node using Neon
高级语言: Rust
项目地址: git://github.com/sqlite-js/sqlite.git
创建时间: 2018-11-01T17:34:46Z
项目社区:https://github.com/sqlite-js/sqlite

开源协议:

下载


sqlite

🚧 A Work in Progress. Do Not Use 🚧

Build Status

An experimental SQLite library for Node using Neon

Goals

  • APIs
    • Query binding
    • Connection creation and closing
    • Connection pooling
    • Parallel queries
    • Serialization
    • Traces and profiling
    • Interrupting queries
    • Exporting a database
  • Modern infrastructure
  • Target latest node and electron versions
  • Promise based API
  • Blob support
  • ESNext BigInt support
  • SQLite extensions support
  • Typescript support
  • Query caching support
  • Extensive documentation and examples using docusarus, guides and examples
  • Bundle sqlite if system does not have it installed
  • Support for larger subset of SQLite API (compared to node-sqlite3)
  • Better performance (compared to node-sqlite3)

Ideal API

  1. import Sqlite from '@sqlite/sqlite';
  2. const connector = new Sqlite();
  3. // Creating a regular async connection
  4. const conn = await connection.open({
  5. database: '/path/to/database', // ':memory:'
  6. verbose: true // process.env.NODE_ENV !== 'production'
  7. });
  8. // Parallel queries
  9. await Promise.all([
  10. conn.run('SELECT * FROM users'),
  11. conn.run('UPDATE tbl SET name = ? WHERE email = ?', 'bar', 2)
  12. ]);
  13. // Statement currying
  14. const updateTables = await db.statement('UPDATE tbl SET name = ? WHERE email = ?');
  15. const result = await updateTables('john', 'john@gmail.com');
  16. console.log(result);
  17. // Batching queries
  18. const updateTables = await db.batch(
  19. `
  20. ATTACH DATABASE ':memory:' AS my_attached;
  21. BEGIN;
  22. CREATE TABLE my_attached.foo(x INTEGER);
  23. INSERT INTO my_attached.foo VALUES(42);
  24. END
  25. `;
  26. );
  27. const updateTables = await db.batch([
  28. 'ATTACH DATABASE ':memory:' AS my_attached;',
  29. 'BEGIN;',
  30. 'CREATE TABLE my_attached.foo(x INTEGER);',
  31. 'INSERT INTO my_attached.foo VALUES(42);',
  32. 'END'
  33. ]);

Local Development

  1. git clone https://github.com/sqlite-js/sqlite
  2. cd sqlite
  3. yarn
  4. yarn test

Prior art

Yarn wouldn’t exist if it wasn’t for excellent prior art. Sqlite has been inspired by the following projects: