A library for interacting with SQLite databases
Go to file
2021-03-04 20:07:13 -08:00
lib Added debug message when registering adapters 2021-03-04 20:07:13 -08:00
src Added debug message when registering adapters 2021-03-04 20:07:13 -08:00
.gitignore Initial commit 2021-03-01 18:47:07 -08:00
package-lock.json Fixed webpack configuration issue and updated webpack 2021-03-02 17:56:45 -08:00
package.json Fixed webpack configuration issue and updated webpack 2021-03-02 17:56:45 -08:00
README.md Added README 2021-03-02 19:11:08 -08:00
webpack.config.js Fixed webpack configuration issue and updated webpack 2021-03-02 17:56:45 -08:00

PawSQLite

PawSQLite is a library for interacting with SQLite databases. Through the use of multiple adapters for various environments, it provides a simple API that abstracts out implementation specific quirks.

Installation

You can install using npm:

npm install -s git+https://git.n0m.org/n0m/PawSQLite.git

In order to actually use PawSQLite, you must also install an adapter for your specific environment. Currently, adapters are available for the following environments:

WebSQL:

PawSQLite-WebSQL-Adapter: https://git.n0m.org/n0m/PawSQLite-WebSQL-Adapter

Apache Cordova:

PawSQLite-Cordova-Adapter: https://git.n0m.org/n0m/PawSQLite-Cordova-Adapter

Node.js via Sqlite3 package:

Coming Soon!

Usage

const PawSQLite = require("pawsqlite");
const PawSQLiteWebSQLAdapter = require("pawsqlite-websql-adapter");

PawSQLite.registerAdapter(PawSQLiteWebSQLAdapter)

const db = await PawSQLite.open("test", {
  adapter: 'PawSQLiteWebSQLAdapter'
});

await db.sql(`
  CREATE TABLE contacts (
    contact_id INTEGER PRIMARY KEY,
    first_name TEXT NOT NULL,
    last_name TEXT NOT NULL
  );
`);

const transaction = db.transaction();

console.log(await db.sql("SELECT * FROM contacts"));

await transaction.sql(
  "INSERT INTO contacts (first_name, last_name) VALUES (?, ?)",
  "John",
  "Lennon"
);

await transaction.commit();

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT