Getting started with sqlite react-native (part 1)

React Native

Home » Blog » Javascript » React Native » Getting started with sqlite react-native (part 1)

Sqlite is the sql database engine for the mobile devices. It provides the relational database features as in the SQL only the difference is the basic syntax format. Expo has recently added the support for the SQLite for RN (React Native). In this post I will simply share a insert operation only.

First import the SQLite from the Expo and initialize a database

Next we have to write a code to define our schema

The “PRAGMA foreign_keys=on” is required while maintaining the relationship of one entity with the other one. In the above schema a ‘Class’ and ‘Student’ has one-to-many relationship.

For the basic example , let’s start with the basic insert command .

You can save all these code inside a Schema.js file and call the insert function passing any string. In the next part, we will get started with the CRUD operation and showing the data in the FlatList.

About Author

nyasin585

×