• Stars
    star
    376
  • Rank 113,543 (Top 3 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SQLite3 Native Plugin for React Native for iOS, Android, Windows and macOS.

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 Inkdrop

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 editing 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))
    }
  })
})

See an example project for more detail.

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' })

Foreign key support

As part of database initialization, this library will enable foreign key support automatically on both iOS & Android. Thus, any tables that define foreign key constraints will have them enforced whether or not foreign key support is explicitly enabled/disabled by PRAGMA statements sent via SQL.

Changelog

See CHANGELOG.md

Contributing

See CONTRIBUTING.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.

More Repositories

1

dotfiles-public

My personal dotfiles
Lua
6,132
star
2

craftzdog-homepage

My homepage
JavaScript
2,257
star
3

chat-bubbles-for-yt

Real-time recording for chat bubbles
TypeScript
658
star
4

solarized-osaka.nvim

🏯 A clean, dark Neovim theme written in Lua, with support for lsp, treesitter and lots of plugins.
Lua
595
star
5

react-native-animated-todo

Animated ToDo app built with React Native and Reanimated v2
TypeScript
444
star
6

react-native-quick-base64

A fast base64 module for React Native
TypeScript
354
star
7

electron-markdown-editor-tutorial

Electron Markdown editor tutorial
JavaScript
298
star
8

craftzdog-uses

A curated list of the tech I use, built with Astro and Tailwind CSS
Astro
251
star
9

react-native-aes-gcm-crypto

AES-GCM encryption/decryption for React Native
Java
242
star
10

inkdrop-ui-mockup-react-native

A mockup for Inkdrop mobile inspired by Gmail
TypeScript
236
star
11

react-native-checkbox-reanimated

Animated checkbox built with Reanimated v2
TypeScript
165
star
12

link-in-bio

Link in bio page for my Instagram profile
HTML
165
star
13

ghibli-style-shader

Ghibli-styled Shader Example for Three.js
JavaScript
150
star
14

vlog-translator

A Personal Tool for Transcribing & Translating My Vlogs into Japanese
TypeScript
144
star
15

pouchdb-adapter-react-native-sqlite

PouchDB adapter using ReactNative SQLite as its backing store
JavaScript
116
star
16

react-native-quick-md5

Fast C++ implementation with JSI binding of MD5 for React Native
C++
106
star
17

caffe-ios-sample

An example of XCode project using Caffe: a fast open framework for deep learning
Objective-C++
98
star
18

ZenPlayer-for-iOS

ZenPlayer written with objective-c
Objective-C
91
star
19

hyper-holoplay

Holoplay integration for Hyper
JavaScript
82
star
20

cm6-themes

Themes for CodeMirror 6
TypeScript
80
star
21

voxel-dog

A cute 3D dog rendered with three.js
TypeScript
71
star
22

send-email-lambda

Simple email sender running on Lambda
JavaScript
69
star
23

react-native-three-column-layout

Three-column layout with animation support for tablet displays
TypeScript
48
star
24

react-native-quick-websql

Fast WebSQL-compatible SQLite driver for React Native
TypeScript
44
star
25

NRBlurryStepOutAnimatedTransitioning

tweetbot like modal view transitioning
Objective-C
42
star
26

react-native-skeuomorphism-ui-example

Neo-skeuomorphism style UI Example for React Native
JavaScript
38
star
27

p5-wave-visualization

p5 sketch visualizing the sound of waves of the sea recorded at Yuigahama in Kamakura, which is processed with FFT.
JavaScript
36
star
28

react-native-japanese-tokenizer

Async Japanese Tokenizer Native Plugin for React Native for iOS and Android
Java
34
star
29

smooth-toc-example

A demo project of a smoothly animated table of contents
CSS
30
star
30

react-codemirror-runmode

Syntax highlighting for react, utilizing CodeMirror's parser
TypeScript
27
star
31

presentation-themes

Presentation themes based on popular syntax themes
19
star
32

gatsby-starter-ionic

A Gatsby starter with Ionic added on top
CSS
17
star
33

atom-react-app

An empty React app based on Atom Editor
JavaScript
16
star
34

pouchdb-react-native-demo

A working demo for PouchDB on React Native with SQLite3 storage
JavaScript
15
star
35

extract-main-text-node

ExtractContent for node.js
JavaScript
15
star
36

react-native-native-ui-component-boilerplate

My boilerplate for building a native UI component for React Native
Java
13
star
37

remark-react-codemirror

Syntax highlighting for remark-react through CodeMirror
JavaScript
11
star
38

remark-strip-html

Remove html formatting from Markdown
JavaScript
11
star
39

anavi-phat-sensors-ui

Web interface for ANAVI pHAT & CO2 sensors
CSS
10
star
40

react-native-sqlite-2-demo

React Native SQLite 2 Demo
JavaScript
5
star
41

anavi-sensors-api

An API server to retrieve ANAVI sensor data from my Raspberry Pi
JavaScript
4
star
42

rn-tamagui-web-test

TypeScript
4
star
43

lunr-language-jp

A Japanese tokenizer and stopwords for Lunr JavaScript library
JavaScript
3
star
44

frosted-top-bar-example

an example of iOS like frosted blurry-styled top-bar on the web
HTML
3
star
45

raspcon

A remote controller server for my room πŸ•Ή
JavaScript
2
star
46

twit-promise

A wrapper for the Twit module that its get/post methods return the native promise
JavaScript
2
star
47

NRJSONHelpers

Handy categories for encoding/decoding JSON in Objective-C
Objective-C
1
star
48

codemirror.next-markdown

Markdown test
1
star
49

electron-acrylic-window-drag-issue-reproduction

JavaScript
1
star
50

react-native-pouchdb-md5

PouchDB utilities for calculating MD5 checksums for React Native
Java
1
star