Infinitbility
Published in

Infinitbility

React Native SQLite Storage

Examples of Query Uses In SQLite

React Native SQLite is a library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.

React Native SQLite with infinitbility

Installation

SQLite is famous for its great feature of zero-configuration, which means no complex setup or administration is needed.

Create a New Application

$ npx react-native init SQLite$ cd SQLite$ cd android$ gradlew clean

Run Your Project

$ cd ..$ npx react-native run-android

Install React Native SQLite Storage

$ npm install --save react-native-sqlite-storage$ react-native link react-native-sqlite-storage

Setup SQLite Database

For managing SQLite Download SQLite Browser

Using DB Browser for SQLite we are create autoloaded data on SQLite

Create Database

Create a New Database file using SQLite Browser in your Project Folder/android/app/src/main/assets directory

Create Database

Use Database

below code adds on your App.js file. on this code doing creating Global Variable Db for connection database and use in all my screen.

Use SQLite Database on React Native

Queries Of SQLite Index

Here, You will see some examples of queries and problems to execute the query.

Examples Of Query

  1. Create Table Query
  2. Insert Query
  3. Update Query
  4. Delete Query
  5. select Query
  6. Joins Query

Problems To Execute Query

  1. Multiple Query Run At a Time Issue ( Use Promise on Execute Query)

if you are facing multiple select query issues then please my Execute Query function. on this function, we are using promise for all queries.

Multiple Argument ( Param ) on Query

For this, please check the query example.

Examples Of Query

Examples Of Query You will learn Basic CRUD operation on SQLite and Joins Query.

Read Original Documentation For an example of SQLite queries

Create Table Query

Created ExecuteQuery function and it’s common for all queries to Execute. it’s handle promise also. using this function you can run multiple queries at a time.

https://infinitbility.com/react-native-sqlite-storage-examples-of-query#create-table-query

Insert Query

SQLite INSERT INTO Statement is used to add new rows of data into a table in the database.

https://infinitbility.com/react-native-sqlite-storage-examples-of-query#insert-query

Update Query

SQLite UPDATE Query is used to modifying the existing records in a table. You can use the WHERE clause with the UPDATE query to update selected rows, otherwise, all the rows would be updated.

https://infinitbility.com/react-native-sqlite-storage-examples-of-query#update-query

Delete Query

SQLite DELETE Query is used to delete the existing records from a table. You can use the WHERE clause with the DELETE query to delete the selected rows, otherwise, all the records would be deleted.

https://infinitbility.com/react-native-sqlite-storage-examples-of-query#delete-query

Select Query

The SQLite select statement is used to fetch the data from an SQLite database table which returns data in the form of a result table. These result tables are also called result sets.

https://infinitbility.com/react-native-sqlite-storage-examples-of-query#select-query

Joins Query

SQLite Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.

Provided Example of

  1. INNER JOIN
  2. LEFT JOIN
  3. RIGHT JOIN
  4. FULL OUTER JOIN

https://infinitbility.com/react-native-sqlite-storage-examples-of-query#joins-query

SQLite Delete Database

created separate posts for delete database and DB file location.

Code Tips

directly store all data on the state if you didn’t want to loop all your rows

For Github Repo

You Want to learn more about SQLite, I recommend

Please Clap if you want to appreciate me and comment on any improvement…

--

--

--

We have the ability to build infinite way for us. follow us for new way…

Recommended from Medium

The Most Effective Way to Protect Client-Side JavaScript Applications

REASONS WHY YOU SHOULD STOP USING JQUERY AND SWITCH TO VUE.JS

Github + CircleCI + Helm + NestJS = A special cocktail to spice up your continuous deployment

MongoDB — The basics

Implement semantic segmentation with npm

React Component Viewer

Build a BREADCRUMB Component Using REACT JS

Nested Arrays — A Christopher Nolan Film

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Infinitbility

Infinitbility

Subscribe my newsletter to get weekly updates. — https://infinitbility.com/about

More from Medium

Display CSV Data in a React Native Table With Pagination

Expo Go “Network response timed out” Error Fix

Filter data by category with React Native and Styled-Components.

React Native Render Loop Element into Ternary Operator.