Reading .sdf file (SQL Server Compact File) in reactnative

153 Views Asked by At

I am trying to open a .sdf SQL Server Compact database file directly into my React application. How can I open it in React Native directly, without any server or need of an API?

I am building an app that will use the scrapped data stored into a database file and based on that generate a timetable. I do have the app built on C# but it's someone's else code and it works on Windows only. It has a separate scrapper that generates C# file. Now, I don't want to redo scrapping all over again.

Basically, I want a React native mobile app that maybe asks to download database file from the internet (my custom url later on like drive link etc) if it's not already there or needs updating and then I am able to read that directly into my react-native application.

Can I do that? There is no clear tutorial of this so far in my searching. I don't want API nor any server extras. Thank you

1

There are 1 best solutions below

0
Ali Shaukat On

Don't know why people are disliking my post that's strange. Anyway, I found the answer to the question and that was to convert the .sdf (SQL Server Compact) database into SQL-Lite database file using .sdf to .sqlite converter

And then in the app, following the answer of hakkikonu from SQLITE database Connection in ReactNative. Put my converted .sqlite file into the assets folder, changed it's extension to .db and used that given code to connect and voila it worked. After that, you can use SQLITE documentation to play around with the data.

Also you can use this amazing tool to browse your SQL-Lite database file as well. DB Browser for SQLite