Problem
I have a large sqlite db (~300mb) and I want to use it to seed my application on load and store to the filesystem to use sqlite queries. For context, it is a language dictionary application.
I have looked around, and I haven't found a solution that is applicable to my situation. Ideally, I understand that I can use the importFromJson function from the @capacitor-community/sqlite" plugin.
The issue with this is, the file seems to be too large + not being able to find applicable examples to implement properly since this is all new to me.
I am following this example : https://github.com/jepiqueau/react-sqlite-app-starter/blob/02809174e3b5bb355e506ed3bf20e1a92c74f860/src/pages/Tab1.tsx#L22
const retImport: any = await sqlite.importFromJson(JSON.stringify(jsonImport));
this line here, If I stringify my data, I am sure this is not going to work since the data would consume too many resources.
Expected Results
I want to be able to import large (~300mb) sqlite OR JSON files to seed my react ionic database to use with Sqlite.
Is there a way I can stream the json file, upload it in chunks? I am aware how to do with fs but I don't know to do with react native + ionic + @capacitor-community/sqlite.
ok! So I solved this for importing a .sqlite db dump for react ionic native using that capacitor sqlite community plugin.
How to import and use a .sqlite file
Export your file from your
sqlite3databasecopy that file into your
public/assets/databasesfolder as<name>.db. Make sure to change the extension to.dbAND also add the definition in yourdatabases.jsonfile in the same directory{ "databaseList": [ "test_db.db" ] }
Before you connect to the db by name, use the function
await sqlite.copyFromAssets();after importingimport { sqlite, existingConn } from '../App';from theApp.tsxfile as mentioned in the boiler plate I linked before. Please refer to theApp.tsx + Index.tsxfiles.Create the connection and Connect to the db