我是 flutter 的初学者,并尝试在我的应用程序上创建 CRUD 方法,但是在我调用插入方法(addItems)时创建数据库后,有 DatabaseException(没有这样的表:values11(代码 1):这让我感到困惑,我阅读了所有过去的问题并尝试了所有问题,但我现在没有工作,
还有路径:/data/user/0/com.example.mana_app/app_flutter/mana_appp.db, 是吗??
未来的 init() 异步 {
Directory directory = await getApplicationDocumentsDirectory();
final path = join(directory.path, "mana_appp.db");
print('paath is here: $path');
return await openDatabase(
path,
version: 6,
onCreate: (Database db4, int version) async {
await db4.execute(
"CREATE TABLE IF NOT EXISTS VALUE_TABLE11 ("
"id INTEGER PRIMARY KEY"
"chicken_no INTEGER NOT NULL,"
"insured_chick INTEGER NOT NULL,"
"rise_durate_m TEXT NOT NULL,"
"death_10days INTEGER NOT NULL,"
"death_21days INTEGER NOT NULL,"
"death_35days INTEGER NOT NULL,"
"death_after_35d INTEGER NOT NULL,"
"chick_weight REAL NOT NULL,"
"convert_coficient REAL NOT NULL,"
"cnsume_dan REAL NOT NULL,"
"rise_dur_da REAL,)"
);
},
);
}
}
Future<int> addItem(model_values costs) async {
final Database db3 = await init();
await db3.insert(VALUE_TABLE11, costs.tomap(),
conflictAlgorithm: ConflictAlgorithm.replace
);
}
类模型值{
int id;
int chicken_no;
int insured_chick;
double rise_durate_m;
int death_10days;
int death_21days;
int death_35days;
int death_after_35d;
double chick_weight;
double convert_coficient;
double cnsume_dan;
double rise_dur_da;
model_values({this.id, this.chicken_no ,this.insured_chick,this.rise_durate_m,
this.death_10days,this.death_21days,this.death_35days,this.death_after_35d,
this.chick_weight,this.convert_coficient,this.cnsume_dan,this.rise_dur_da,})
}}