0

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.

4

1 回答 1

0

创建 id 列后,您缺少逗号

await db.execute("CREATE TABLE tempsettings("
            "id INTEGER ", //this comma was missing
            "user TEXT,"
            "company TEXT,"
            "url TEXT)")
        .catchError((error) => print(error.toString()));
于 2019-08-23T15:29:31.583 回答