All Projects → craftzdog → React Native Sqlite 2

craftzdog / React Native Sqlite 2

Licence: apache-2.0
SQLite3 Native Plugin for React Native for iOS, Android, Windows and macOS.

Projects that are alternatives of or similar to React Native Sqlite 2

Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+483.87%)
Mutual labels:  sqlite, sqlite3
Sqhell.vim
An SQL wrapper for vim
Stars: ✭ 113 (-47.93%)
Mutual labels:  sqlite, sqlite3
Genomicsqlite
Genomics Extension for SQLite
Stars: ✭ 90 (-58.53%)
Mutual labels:  sqlite, sqlite3
D2sqlite3
A small wrapper around SQLite for the D programming language
Stars: ✭ 67 (-69.12%)
Mutual labels:  sqlite, sqlite3
Sqlittle
Pure Go SQLite file reader
Stars: ✭ 171 (-21.2%)
Mutual labels:  sqlite, sqlite3
Liszt
A personal organization software with a script engine for automation
Stars: ✭ 72 (-66.82%)
Mutual labels:  sqlite, sqlite3
Sqlite3 Encryption
The easiest way to build SQLite3 with encryption support on Windows. Compilation of DLL, SLL or shell is now a matter of minutes
Stars: ✭ 102 (-53%)
Mutual labels:  sqlite, sqlite3
Fluent Sqlite Driver
Fluent driver for SQLite
Stars: ✭ 51 (-76.5%)
Mutual labels:  sqlite, sqlite3
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (-22.12%)
Mutual labels:  sqlite, sqlite3
Sqlite Parquet Vtable
A SQLite vtable extension to read Parquet files
Stars: ✭ 167 (-23.04%)
Mutual labels:  sqlite, sqlite3
Sqlite orm
❤️ SQLite ORM light header only library for modern C++
Stars: ✭ 1,121 (+416.59%)
Mutual labels:  sqlite, sqlite3
Pydbgen
Random dataframe and database table generator
Stars: ✭ 191 (-11.98%)
Mutual labels:  sqlite, sqlite3
Electron Angular4 Sqlite3
Sample project to show how to build a desktop app using Electron, Angular 4 and Sqlite3
Stars: ✭ 60 (-72.35%)
Mutual labels:  sqlite, sqlite3
Electron With Sqlite3
Sample application for ElectronJS working with Sqlite3
Stars: ✭ 83 (-61.75%)
Mutual labels:  sqlite, sqlite3
Esp32 Idf Sqlite3
Sqlite library for esp-idf (esp32) framework
Stars: ✭ 57 (-73.73%)
Mutual labels:  sqlite, sqlite3
Pouchdb Adapter React Native Sqlite
PouchDB adapter using ReactNative SQLite as its backing store
Stars: ✭ 98 (-54.84%)
Mutual labels:  sqlite3, pouchdb
Sqlitelib
Easily build a custom SQLite static library for use in macOS and iOS frameworks and apps.
Stars: ✭ 38 (-82.49%)
Mutual labels:  sqlite, sqlite3
Perfect Sqlite
A stand-alone Swift wrapper around the SQLite 3 client library.
Stars: ✭ 42 (-80.65%)
Mutual labels:  sqlite, sqlite3
Esp32 arduino sqlite3 lib
Sqlite3 Arduino library for ESP32
Stars: ✭ 167 (-23.04%)
Mutual labels:  sqlite, sqlite3
Choochoo
Training Diary
Stars: ✭ 186 (-14.29%)
Mutual labels:  sqlite, sqlite3

React Native SQLite 2

SQLite3 Native Plugin for React Native for Android, iOS, Windows and macOS. This plugin provides a WebSQL-compatible API to store data in a react native app, by using a SQLite database on the native side.

Inspired by fantastic work done by Nolan Lawson. It should be a drop-in replacement for react-native-sqlite-storage. It works pretty well with PouchDB on React Native app.

Used by

mozilla / notes

Why?

The reason for this plugin is that react-native-sqlite-storage has some problems when used with PouchDB:

This plugin solves these problems.

Newer SQLite3 on Android

Even the latest version of Android is several versions behind the latest version of SQLite, whereas iOS has newer version. React Native SQLite 2 uses sqlite-android which allows you to use the latest version of it with new SQLite features enabled:

Getting started

Add react-native-sqlite-2 to your dependencies:

$ npm install react-native-sqlite-2 --save

Link native dependencies

From react-native 0.60 autolinking will take care of the link step but don't forget to run pod install.

$ react-native link react-native-sqlite-2

iOS/macOS

If using cocoapods in the ios/ directory run

$ pod install

Android

Please make sure AndroidX is enabled in your project by editting android/gradle.properties and adding 2 lines:

android.useAndroidX=true
android.enableJetifier=true

Usage

import SQLite from "react-native-sqlite-2";

const db = SQLite.openDatabase("test.db", "1.0", "", 1);
db.transaction(function (txn) {
  txn.executeSql("DROP TABLE IF EXISTS Users", []);
  txn.executeSql(
    "CREATE TABLE IF NOT EXISTS Users(user_id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(30))",
    []
  );
  txn.executeSql("INSERT INTO Users (name) VALUES (:name)", ["nora"]);
  txn.executeSql("INSERT INTO Users (name) VALUES (:name)", ["takuya"]);
  txn.executeSql("SELECT * FROM `users`", [], function (tx, res) {
    for (let i = 0; i < res.rows.length; ++i) {
      console.log("item:", res.rows.item(i));
    }
  });
});

There is a test app in the test directory.

Using with PouchDB

It can be used with pouchdb-adapter-react-native-sqlite.

import PouchDB from "pouchdb-react-native";
import SQLite from "react-native-sqlite-2";
import SQLiteAdapterFactory from "pouchdb-adapter-react-native-sqlite";

const SQLiteAdapter = SQLiteAdapterFactory(SQLite);
PouchDB.plugin(SQLiteAdapter);
var db = new PouchDB("mydb", { adapter: "react-native-sqlite" });

Troubleshooting

Row too big to fit into CursorWindow (Android)

You can set a limited windowSizeBytes for CursorWindow and try-catch the exception by adding following code to your MainApplication.onCreate in MainApplication.java:

try {
  Field field = CursorWindow.class.getDeclaredField("sCursorWindowSize");
  field.setAccessible(true);
  field.set(null, 100 * 1024 * 1024); //the 100MB is the new size
} catch (Exception e) {
  if (DEBUG_MODE) {
    e.printStackTrace();
  }
}

Note that it requires Android 9 (API level 28).

Changelog

See CHANGELOG.md

Original Cordova SQLite Bindings from Nolan Lawson

https://github.com/nolanlawson/cordova-plugin-sqlite-2

The issues and limitations for the actual SQLite can be found on this site.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].