Creating an app with react native
You have installed expo-sqlite to use client db.
I created a db file, put it in the project directory, and entered a dummy record.
However, the callback function that displays the results is not executed. I don't know where the problem is.
import React, {Component} from 'react';
import {View} from 'react-native';
import * as SQLite from 'expo-sqlite'
class INPUT extends Component{
constructor(){
const db = SQLite.openDatabase('record.db');
db.transaction(
tx => {
tx.executeSql(
'select * from record',
[],
(trans, result) => {
console.log(result)
}
);
}
);
}
render(){
return(
<View>
</View>
)
}
}
export default INPUT
constructor(props){
super(props)
this.state={
}
db.transaction(tx => {
tx.executeSql(
'CREATE TABLE IF NOT EXISTS names (num INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, target TEXT, display INTEGER);'
);
})
}
You can solve it by using the keyword IF NOT EXISTS in this way in the constructor.
598 Uncaught (inpromise) Error on Electron: An object could not be cloned
877 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
595 GDB gets version error when attempting to debug with the Presense SDK (IDE)
566 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.