Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I was trying hard to make a connection to sqlite db using react-native-sqlite-storage, I copied the steps in github, it worked perfectly on android but not on IOS, It is unable to find db file even I put it in the supposed folder "iOS/www", here is the open statement:

import {openDatabase} from 'react-native-sqlite-storage';

.....

const database = openDatabase({

      name: 'hebron_db.db',

      createFromLocation: '~hebron_db.db',

      location: 'default'

}, () => {

   console.log('db connection success')

}, () => {

   console.log('db connection error')

});

It states that "db connection success" even when I type wrong file name.

I use react native 0.62.2 Xcode: 11.5 npm: 6.13.4 macOS: Catalina 10.15.5

Any help will be much appreciated.

1 Answer

0 votes
by (11.7k points)

Tryout this connection string, it worked fine for me:

import {openDatabase} from 'react-native-sqlite-storage';

const database = openDatabase({name : "hebron_db", createFromLocation : 1}, null, null);

export default database;

If you want to get more insights into SQL, checkout this SQL Course from Intellipaat.

Related questions

0 votes
4 answers
asked Feb 25, 2021 in SQL by adhiraj (4k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...