const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) {
rdbStore.executeSql(SQL_CREATE_TABLE)
console.info(TAG + 'create table done.')
})
import Ability from '@ohos.application.Ability'
import data_rdb from '@ohos.data.rdb'
export default class MainAbility extends Ability {
const STORE_CONFIG = { name: "RdbTest.db"}
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) {
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
let promise = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1);
promise.then(async (rdbStore) => {
await rdbStore.executeSql(SQL_CREATE_TABLE, null)
}).catch((err) => {
expect(null).assertFail();
})
import Ability from '@ohos.application.Ability'
import data_rdb from '@ohos.data.rdb'
export default class MainAbility extends Ability {
const STORE_CONFIG = { name: "RdbTest.db" }
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
let promise = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1);