React Native apps come with a simple user interface, code reusability, and allows for the production of stable apps. With React-Native being one of the most popular and ideal frameworks for creating cross-platform mobile applications, the vast majority of the developers and engineers depend on the structure of the framework to deliver high-performing local applications. Because of this, it’s often challenging for developers to choose the right technology stack (including the appropriate database for React Native). In this article we will be discussing SQLite as a local database for React-Native, and work on how to pre-populate data into the database so as to use it in the application.
React Native应用程序具有简单的用户界面,代码可重用性,并允许生产稳定的应用程序。 由于React-Native是用于创建跨平台移动应用程序的最受欢迎和理想的框架之一,因此绝大多数开发人员和工程师都依赖于框架的结构来交付高性能的本地应用程序。 因此,对于开发人员而言,选择正确的技术堆栈(包括适用于React Native的适当数据库)通常具有挑战性。 在本文中,我们将讨论SQLite作为React-Native的本地数据库,并研究如何将数据预填充到数据库中以便在应用程序中使用。
The word “lite” in SQLite describes it as being a lightweight library based database which requires minimal setup. SQLite can be coordinated with a versatile application, allowing us to get to the database in an easy, straightforward manner. It’s also helpful to note that SQLite was designed to provide local storage to mobile apps.
SQLite中的“ lite”一词将其描述为基于轻量级库的数据库,需要最少的设置。 SQLite可以与通用应用程序配合使用,使我们能够以简单,直接的方式访问数据库。 注意到SQLite旨在为移动应用程序提供本地存储也很有帮助。
The two main benefits of using SQLite database are:
使用SQLite数据库的两个主要好处是:
It’s ACID-compliant (an acronym for atomicity, consistency, isolation, and durability)
它符合ACID( 原子性 , 一致性 , 隔离 性和耐用 性的首字母缩写)
- Its offline persistence (which means that it works even when the device is offline) 它的离线持久性(这意味着即使设备离线也可以工作)
建立资料库 (Creating a database)
First, we need to create a database and store some data in it. https://sqliteonline.com/ can help in creating a SQLite database.
首先,我们需要创建一个数据库并在其中存储一些数据。 https://sqliteonline.com/可以帮助创建SQLi