我可以得到一些帮助吗...我得到的错误像
1) near "VALUES": syntax error
I/flutter ( 6415): DatabaseException(near "VALUES": syntax error (code 1 SQLITE_ERROR): , while compiling: INSERT INTO words (
这是我的dart模型代码。它说这里有问题
[点击此处][1]
Wordtable是我保存数据的SQLite模型,Word是我获取数据并保存到SQLite one中的后端模型
我试图使它尽可能简短和准确,所以请让我知道,如果任何进一步的澄清是需要的。谢谢你,新年快乐
class WordList {
List<Word>? words;
WordList({this.words});
factory WordList.fromJson(List<dynamic> json, String lang) {
List<Word> words = json.map((i) => Word.fromJson(i, lang)).toList();
return new WordList(
words: words,
);
}
}
class WordTableList {
final List<WordTable>? words;
WordTableList({this.words});
factory WordTableList.fromJson(List<dynamic> json) {
List<WordTable> words = json.map((e) => WordTable.fromMap(e)).toList();
return new WordTableList(
words: words,
);
}
}
////////////////////WordTable SQLLITE/////////////////////
class WordTable {
static String table = 'words';
int? WORD_ID;
String? TINA;
String? LETTER;
String? NABA;
String? ITAVI;
String? LOMANIBAI;
String? DEWA;
String? IVAKAMACALA;
String? COKE;
String? IDUSIDUSI;
// String? LINKED_SYN;
String? IVOSAVOSA;
String? ITAKATAKA;
String? VOSA_VAKALATINA;
String? WORDIMG;
String? MAIN_AUDIO;
String? STORY_AUDIO;
WordTable.fromJson(Map<String, dynamic> json) {
this.WORD_ID = json['word_id'];
this.TINA = json['tina'];
this.LETTER = json['letter'];
this.NABA = json['naba'];
this.ITAVI = json['itavi'];
this.LOMANIBAI = json['lomanibai'];
this.DEWA = json['dewa'];
this.IVAKAMACALA = json['ivakamacala'];
this.COKE = json['coke'];
this.IDUSIDUSI = json['idusidusi'];
//this.LINKED_SYN = json['ivosavosa'];
this.IVOSAVOSA = json['ivosavosa'];
this.ITAKATAKA = json['itakataka'];
this.VOSA_VAKALATINA = json['vosa_vakalatina'];
this.WORDIMG = json['word_main_image'];
this.MAIN_AUDIO = json['word_main_audio'];
this.STORY_AUDIO = json['story_audio'];
// if (json['family'] != null) {
// this.plantFamily = PlantFamily.fromJson(json['family']);
// }
}
WordTable.fromMap(Map<String, dynamic> json) {
this.WORD_ID = json['word_id'] == null ? 0 : json['word_id'];
this.TINA =
json['tina'] == null ? "No Scientific Name Available" : json['tina'];
this.LETTER =
json['letter'] == null ? "No Local Name Available" : json['letter'];
this.NABA = json['naba'] == null
? "storage/images/13293205681610263850.png"
: json['naba'];
this.ITAVI =
json['itavi'] == null ? "No Description Available" : json['itavi'];
this.LOMANIBAI = json['lomanibai'] == null
? "No Description Available"
: json['lomanibai'];
this.DEWA =
json['dewa'] == null ? "No Distribution Available" : json['dewa'];
this.IVAKAMACALA = json['ivakamacala'] == null
? "No Distribution Available"
: json['ivakamacala'];
this.COKE =
json['coke'] == null ? "No Distribution Available" : json['coke'];
this.IDUSIDUSI = json['idusidusi'] == null
? "No Description Available"
: json['idusidusi'];
this.IVOSAVOSA = json['ivosavosa'] == null
? "No Description Available"
: json['ivosavosa'];
this.ITAKATAKA = json['itakataka'] == null
? "No Description Available"
: json['itakataka'];
this.VOSA_VAKALATINA = json['vosa_vakalatina'] == null
? "No Description Available"
: json['vosa_vakalatina'];
this.WORDIMG = json['word_main_image'] == null
? "No Description Available"
: json['word_main_image'];
this.MAIN_AUDIO = json['word_main_audio'] == null
? "No Description Available"
: json['word_main_audio'];
this.STORY_AUDIO = json['story_audio'] == null
? "No Description Available"
: json['story_audio'];
// this.hpfMedicalUseOtherFj = json['hpf_medical_use_other_fj'] == null
// ? "No Description Available"
// : json['hpf_medical_use_other_fj'];
// if (json['plant_family'] != null) {
// print('family is not null');
// this.plantFamily = new PlantFamily(
// bookChapterId: 0,
// hpfBotanicalCat: json['plant_botanical_category'],
// hpfBotanicalSubCat: json['plant_sub_botanical_category'],
// hpfFamilyName: json['plant_family'],
// id: 0);
//}
}
static String plantTableQuery(WordTable words) {
return ''' INSERT INTO words (
word_id,
tina,
letter,
naba,
itavi,
lomanibai,
dewa,
ivakamacala,
coke,
idusidusi,
ivosavosa,
itakataka,
vosa_vakalatina,
word_main_image,
word_main_audio,
story_audio,
VALUES (
'${words.WORD_ID}',
'${words.TINA}',
'${words.LETTER}',
'${words.NABA}',
'${words.ITAVI}',
'${words.LOMANIBAI}',
'${words.DEWA}',
'${words.IVAKAMACALA}',
'${words.COKE}',
'${words.IDUSIDUSI}',
'${words.IVOSAVOSA}',
'${words.ITAKATAKA}',
'${words.VOSA_VAKALATINA}',
'${words.WORDIMG}',
'${words.MAIN_AUDIO}',
'${words.STORY_AUDIO}'
)''';
}
static const String CREATE_TABLE = '''CREATE TABLE IF NOT EXISTS words (
word_id INTEGER PRIMARY KEY,
tina TEXT,
letter TEXT,
naba TEXT,
itavi TEXT,
lomanibai TEXT,
dewa TEXT,
ivakamacala TEXT,
coke TEXT,
idusidusi TEXT,
ivosavosa TEXT,
itakataka TEXT,
vosa_vakalatina TEXT,
word_main_image TEXT,
word_main_audio TEXT,
story_audio TEXT,
)''';
static const String DELETE_TABLE = 'DROP TABLE IF EXISTS words';
}
//////////////////////////////WordTable SQLLITE END////////////////////////////////
class Word {
static String table = 'words';
int? WORD_ID;
String? TINA;
String? LETTER;
String? NABA;
String? ITAVI;
String? LOMANIBAI;
String? DEWA;
String? IVAKAMACALA;
String? COKE;
String? IDUSIDUSI;
String? LINKED_SYN;
String? IVOSAVOSA;
String? ITAKATAKA;
String? VOSA_VAKALATINA;
String? WORDIMG;
String? MAIN_AUDIO;
String? STORY_AUDIO;
Word(
{this.WORD_ID,
this.TINA,
this.LETTER,
this.NABA,
this.ITAVI,
this.LOMANIBAI,
this.DEWA,
this.IVAKAMACALA,
this.COKE,
this.IDUSIDUSI,
this.LINKED_SYN,
this.IVOSAVOSA,
this.ITAKATAKA,
this.VOSA_VAKALATINA,
this.WORDIMG,
this.MAIN_AUDIO,
this.STORY_AUDIO});
factory Word.fromJson(Map<String, dynamic> json, String lang) {
return Word(
WORD_ID: json['word_id'] ?? "0",
TINA: json['tina'] ?? "",
LETTER: json['letter'] ?? "",
NABA: json['naba'] ?? "0",
ITAVI: json['itavi'] ?? "0",
LOMANIBAI: json['lomanibai'] ?? "",
DEWA: json['dewa'] ?? "",
IVAKAMACALA: json['ivakamacala'] ?? "No Description Provided",
COKE: json['coke'] ?? "",
IDUSIDUSI: json['idusidusi'] ?? "",
IVOSAVOSA: json['ivosavosa'] ?? "",
ITAKATAKA: json['itakataka'] ?? "",
VOSA_VAKALATINA: json['vosa_vakalatina'] ?? "",
WORDIMG: json['word_main_image'] ?? "",
MAIN_AUDIO: json['word_main_audio'] ?? "",
STORY_AUDIO: json['story_audio'] ?? "");
}
}
2条答案
按热度按时间lx0bsm1f1#
plantTableQuery
中的查询不完整:SQLite has diagrams on their website,显示命令的语法。它们显示在
CREATE TABLE
查询中:column-name
s应该用括号括起来(您没有右括号)
)column-name
s之间有逗号,但右括号)
之前不能有逗号。CREATE TABLE
diagram显示变量CREATE_TABLE
中的查询在括起column-def
s的右括号)
之前不能有逗号,或者:63lcw9qa2#
在值附近的INSERT查询中存在语法错误。
插页应采用以下格式
列story_audio后面缺少右括号。