I am working integrating SQFLite plugin in a flutter. For the first time table is created and everything is working but when I try to open the database for the second time for running query it gives me a sqflite error.
<code>
Future<Database> initializeDatabase() async {
io.Directory documentsDirectory = await getApplicationDocumentsDirectory();
String path = join(documentsDirectory.path, databaseName);
Database database = await openDatabase(
path,
version: 1,
onCreate: (Database db, int newVersion) async {
await db.execute(
'''
CREATE TABLE $tableName(ss INTEGER , dd TEXT, uu TEXT)''',
);
print("Created tables");
},
);
return database;
}
insert() async {
Database db = await database;
var id = await db.insert(
tableName,
{
'ss': 1,
'dd': "sdsds",
'uu': "vvvvvvv",
},
);
return id;
// await db.close();
}
</code>
对于第一个插入查询,一切正常,但第二次出现以下错误:- 错误:- 调用 sqlite3_step 时出错(1:无法回滚 - 没有事务处于活动状态) SQLITE_ERROR DB 查询:ROLLBACK 完成或重置语句未知错误(1:不能回滚 - 没有事务处于活动状态)数据库查询:ROLLBACK