// 1导入模块
import relationalStore from '@ohos.data.relationalStore';export class AthUserDbManager{//2.获取RdbStore实例,要注意的是,此处的getContext(this)用于获取应用上下文:getcreatDbtable(dbname:string){//配置数据库信息:const STORE_CONFIG :relationalStore.StoreConfig= {name: dbname, // 数据库文件名securityLevel: relationalStore.SecurityLevel.S1, // 数据库安全级别encrypt: false, // 可选参数,指定数据库是否加密,默认不加密// dataGroupId: 'dataGroupID' // 可选参数,仅可在Stage模型下使用,表示为应用组ID,需要向应用市场获取。指定在此Id对应的沙箱路径下创建实例,当此参数不填时,默认在本应用沙箱目录下创建。};//CCDownloding CacheCourse CacheSubCourse Downlodingconst SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS WORKER (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, GENDER TEXT NOT NULL)';relationalStore.getRdbStore(getContext(this),STORE_CONFIG,(err,store)=>{if (err) {console.error(`Failed to get RdbStore. Code:${err.code}, message:${err.message}`);return;}console.info('Succeeded in getting RdbStore.');// 当数据库创建时,数据库默认版本为0// if (store.version === 0) {store.executeSql(SQL_CREATE_TABLE); // 创建数据表// 设置数据库的版本,入参为大于0的整数// store.version = 3;// }})}//3.插入数据insetDBData(dbname:string){const STORE_CONFIG :relationalStore.StoreConfig= {name: dbname, // 数据库文件名securityLevel: relationalStore.SecurityLevel.S1, // 数据库安全级别enc