Cannot import sqlite db from SqLite browser


#1

Hi,

I have followed [SOLVED] Import asset DB but it does not work for me.

I have created a test.db from SqLite Browser on Mac 10.13.6. I placed it in ./assets/db/ next to my App.js.

import Expo, { SQLite, FileSystem, Asset } from ‘expo’;

Expo.FileSystem.downloadAsync(
Expo.Asset.fromModule(require("./assets/db/test.db")).uri,
${Expo.FileSystem.documentDirectory}SQLite/test.db
);

It returns "unable to resolve module for ./assets/db/test.db.

I have in the app.json:

“assetBundlePatterns”: [ “**/*” ],

"packagerOpts": {
  "assetExts": ["db"]
}

In componentDidMount(), I also have:

makeSQLiteDirAsync() {
const dbTest = SQLite.openDatabase(‘dummy.db’);
dbTest.transaction(tx => tx.executeSql(’’));

}

Thank you.


#2

Resolved by adding:

module.exports = {

resolver: {

assetExts: [“db”, “mp3”, “ttf”]

}

}

to metro.config.js.


#3

Glad you got it figured out, @kwantpoxe!


#4

Hi Adam,

Since I can reply now, does the notification saying my account was temporarily placed on hold (which I don’t understand why) no longer applies? Thank you.


closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.