Hi !
I’m currently learning React Native an so using expo which I love but I am facing a wall right now…
I want to loop through data located in a database (using expo-sqlite).
So I firstly download the database like this:
export function downloadDatabases() {
FileSystem.downloadAsync(
Asset.fromModule(require('../assets/db/badic.db')).uri,
`${FileSystem.documentDirectory}SQLite/badic.db`
)
}
Then, I have a function in order to loop through the database:
export function importDatabases() {
let db = SQLite.openDatabase('badic.db');
db.transaction(tx => {
console.log("This is printed");
tx.executeSql(`SELECT * FROM test`, [], (tx, results) => {
console.log("Never printed");
}),
(tx, error) => {
console.log("Never printed either");
}
})
}
As you can see, neither the success or the error arrow functions are getting called. It is exactly the same problem as here: https://www.gitmemory.com/issue/expo/expo/5270/520480859 but the solution given doesn’t solve my case.
My “expo diagnostics”:
Expo CLI 3.1.2 environment info:
System:
OS: Linux 4.4 Ubuntu 18.04.3 LTS (Bionic Beaver)
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 13.0.1 - ~/.nvm/versions/node/v13.0.1/bin/node
npm: 6.12.0 - ~/.nvm/versions/node/v13.0.1/bin/npm
npmPackages:
expo: ^35.0.0 => 35.0.0
react: ^16.8.3 => 16.8.3
react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8
react-navigation: ^4.0.10 => 4.0.10
npmGlobalPackages:
expo-cli: 3.9.0
I call the downloadDatabase function in componentDidMount() and importDatabase() when I press a button component.
I hope you will understand what I mean. Thank you for all the help you will give me.