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.
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
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.
Queries Of SQLite Index
Here, You will see some examples of queries and problems to execute the query.
Examples Of Query
- Create Table Query
- Insert Query
- Update Query
- Delete Query
- select Query
- Joins Query
Problems To Execute Query
- 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
- INNER JOIN
- LEFT JOIN
- RIGHT JOIN
- 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…