flutter - SQLiteLog( 8646): (1) table tempsettings has no column named user
问题描述
I'm learning how to upgrade databases in an flutter application, apears to be very simple, but I'm getting this error executing an INSERT:
E/SQLiteLog( 9107): (1) table tempsettings has no column named user I/flutter ( 9107): DatabaseException(table tempsettings has no column named user (code 1 SQLITE_ERROR): , while compiling: INSERT INTO tempsettings('id', 'user', 'company', 'url') SELECT 'id', 'user', 'company', 'url' FROM settings) E/SQLiteLog( 9107): (1) no such column: user I/flutter ( 9107): DatabaseException(no such column: user (code 1 SQLITE_ERROR): , while compiling: INSERT INTO settings('id', 'user', 'company', 'url', 'theme') SELECT id, user, company, url, 1 FROM tempsettings)
await db
.execute("CREATE TABLE tempsettings("
"'id' INTEGER "
"'user' TEXT,"
"'company' TEXT,"
"'url' TEXT)")
.catchError((error) => print(error.toString()));
await db.execute(
"INSERT INTO tempsettings('id', 'user', 'company', 'url') SELECT 'id', 'user', 'company', 'url' FROM settings")
.catchError((error) => print(error.toString()));
Does anyone could help me how to do this INSERT?
Thanks.
解决方案
创建 id 列后,您缺少逗号
await db.execute("CREATE TABLE tempsettings("
"id INTEGER ", //this comma was missing
"user TEXT,"
"company TEXT,"
"url TEXT)")
.catchError((error) => print(error.toString()));
推荐阅读
- php - 如何将分隔符保留在 preg_split 的下一项中?
- python - AttributeError:模块“子进程”没有属性“c”。子进程中的 c 属性有什么作用?
- android - 无法使用 DownloadManager 从 S3 下载文件
- origen-sdk - 如何使用 output_inhibited?
- php - 在php中的多维数组上搜索具有2个条件的索引的有效方法
- highcharts - Highcharts:突出显示选定/活动按钮
- c++ - 代码块所需文件
- javascript - 防止空白表单提交
- bash - 如何覆盖 bash 配置文件中缺少的 /usr/local/bin
- python - 检查包含单词和短语的列表元素是否存在于另一个列表中