react-native-sqlite icon indicating copy to clipboard operation
react-native-sqlite copied to clipboard

Can't open database

Open JoaoCnh opened this issue 8 years ago • 7 comments

So I created an .sql and .sqlite file through the Terminal.

I created the same table and inserted one row. To see if I could read from it.

I placed the files in the same place as in the react-native-sqlite-example and both of them don't work.

The error message while selecting all rows (select * from table;) basically returns the error message:

No such table: teste (teste is my table btw)

So I see someone here got a similar error. No file is created either. I would love to have this working.

JoaoCnh avatar Sep 30 '15 17:09 JoaoCnh

Did you add the file to the project and make sure that it's being copied to your app in development?

jaygarcia avatar Sep 30 '15 17:09 jaygarcia

I added the file to the project and I didnt quite understand what you meant by "make sure that it's being copied to your app in development".

All I did is put the file in the folder like the example. Since no more instructions were given I thought that was it. Is there something more I should do?

JoaoCnh avatar Sep 30 '15 23:09 JoaoCnh

You shouldn't need to create the files via the terminal. The .sqllite file gets auto-created in the app documents directory if it doesn't exist already. And you can run the sql commands via javascript (to create a table, insert data, etc). It should work. It does for me.

rhaker avatar Oct 02 '15 16:10 rhaker

No files are created for me. What is the relative path to the documents folder?

JoaoCnh avatar Oct 02 '15 16:10 JoaoCnh

You should create a folder in your XCode named Documents and put the sqlite file there. Also verify that the sqlite file is included in the list named Copy Bundle Resources in Build Phases of your project. This worked well form me

ermannos avatar Feb 08 '16 16:02 ermannos

@ermannos Can you explain how to do clearly? I have a problem with database like this. But i've tried to do like you said. But it's not work. Thank you.

diemvtt avatar Sep 28 '16 10:09 diemvtt

Please don't use this library! It's been surpassed by other more recent libraries such as https://github.com/andpor/react-native-sqlite-storage

almost avatar Sep 28 '16 10:09 almost