Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hsjoberg/react-native-turbo-sqlite
A Pure C++ TurboModule for Sqlite
https://github.com/hsjoberg/react-native-turbo-sqlite
new-architecture react-native sqlite turbomodule
Last synced: 21 days ago
JSON representation
A Pure C++ TurboModule for Sqlite
- Host: GitHub
- URL: https://github.com/hsjoberg/react-native-turbo-sqlite
- Owner: hsjoberg
- License: mit
- Created: 2024-10-10T15:48:30.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2024-10-21T15:36:49.000Z (27 days ago)
- Last Synced: 2024-10-21T22:35:40.923Z (26 days ago)
- Topics: new-architecture, react-native, sqlite, turbomodule
- Language: C
- Homepage:
- Size: 3.82 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-turbo-sqlite
A Pure C++ TurboModule for Sqlite.
### Platform support:
```
✅ Android
✅ iOS
✅ macOS
🚫 Windows (planned)
🚫 Linux (maybe)
🚫 Web (maybe)
✅ Jest mocks (uses sql.js)
```## Installation
This lib requires [new architecture](https://reactnative.dev/docs/the-new-architecture/landing-page)
enabled in your app. It will not work on the old architecture and there are no plans to support it.```sh
yarn add react-native-turbo-sqlite
```## Usage
```js
import TurboSqlite from "react-native-turbo-sqlite";
import { DocumentDirectoryPath } from "@dr.pogodin/react-native-fs";// Open the database
const db = TurboSqlite.openDatabase(
DocumentDirectoryPath + "/test.db"
);// Create a table
const createTableResult = db.executeSql(
"CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER)",
[]
);
console.log("Create table result:", createTableResult);// Insert some data
const insertResult = db.executeSql(
"INSERT INTO users (name, age) VALUES (?, ?)",
["Alice", 30]
);
console.log("Insert result:", insertResult);// Select data
const selectResult = db.executeSql("SELECT * FROM users", []);
console.log("Select result:", selectResult);
```## Why yet another sqlite lib?
Current sqlite libs for react-native such as op-sqlite and react-native-quick-sqlite do not support
out-of-tree platforms like react-native-windows and react-native-macos. Instead of working within
those libs I decided to write my own C++ TurboModule that has 100% code-sharing for all platforms.Any other or future out-of-tree platform should easily be supported as long as it supports new
architecture. Let me know if you have any target that you wish should be supported.## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## License
MIT
---
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)