Skip to content

"not an error" on SQL import #1519

Closed
Closed

Description

@VortixDev

Details for the issue

What did you do?

I exported multiple tables from a database into a .sql file, and tried to import it into an existing database.

What did you expect to see?

A message indicating that the import had been completed, or an indication of why the import failed.

What did you see instead?

Upon importing, I received "Error importing data: Error in statement #3: not an error. Aborting execution and rolling back." I copied the content of the .sql file into the "Execute SQL" tab and executed it there, where I was given a better indication of where the issue lay. The file includes references to other tables which were also being imported, and as the referenced tables were created later in the file, this seems to have caused the issue. An example of the SQL that caused the issue is "CONSTRAINT FK_1332519100 FOREIGN KEY(ownerId) REFERENCES libk_player(id) ON DELETE CASCADE ON UPDATE RESTRICT", where the "REFERENCES libk_player" caused issue as libk_player was created later in the file. I had to move the "CREATE TABLE" query for the referenced tables above the queries that referenced them, and that resolved the issue.

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • Windows: (version: 1803 Build 17134)
  • Linux: ( distro: ___ )
  • Mac OS: ( version: ___ )
  • Other: ___

What is your DB4S version?

  • 3.10.1
  • 3.10.0
  • 3.9.1
  • Other: ___

Did you also

Activity

  1. changed the title [-]"no error" on SQL import[/-] [+]"not an error" on SQL import[/+] on Aug 26, 2018
  2. justinclift commented on Aug 26, 2018

    @justinclift
    Member

    As a thought, try with the latest nightly build instead:

        https://nightlies.sqlitebrowser.org/latest/

    We've rewritten large parts of the importing code, so there's a decent chance you'll have a better outcome from that. 😄

  3. VortixDev commented on Aug 26, 2018

    @VortixDev
    Author

    Thanks for the tip! I gave it a try, and for the original file that I was using that seems to work better: the import still produces an error due to the fact that items are inserted into a table which references a non-existent table (as my version completes the INSERTs directly after the table is created, instead of running all INSERTs after all CREATEs).

    I tried to export the same data and import it using the nightly build for both operations, however that seems to still have some issues. I got a "FOREIGN KEY constraint failed" error, however I only got that information from running the query in execute: the actual import feature only gave me the "not an error" message in this case. It seems to me that the issue is having a foreign key referencing another table, but when the data is inserted into the referencing table before it is inserted into the referenced table this causes the error. After re-ordering the INSERTs such that referenced tables are first, it worked.

    It would seem that to have this work smoothly in these cases, the INSERTs need to be re-arranged at either import or export so that any tables which are deepest in the reference chain are inserted first.

  4. justinclift commented on Aug 26, 2018

    @justinclift
    Member

    It would seem that to have this work smoothly in these cases, the INSERTs need to be re-arranged at either import or export so that any tables which are deepest in the reference chain are inserted first.

    Yeah. Thinking about it, that definitely makes sense. I suspect we'll probably not add any kind of "rearrange the table before import" stuff, at least not in the near future.

    But, we should catch the error better/properly instead, then display an appropriate guidance message/thing. eg something so the person doing the import knows what the problem is and how to fix it.

  5. added
    bugConfirmed bugs or reports that are very likely to be bugs.
    on Aug 26, 2018
  6. MKleusberg commented on Aug 27, 2018

    @MKleusberg
    Member

    Thanks for reporting this issue, @VortixDev! I have already pushed a fix for the error message thing. So in tomorrow's nightly build you should get a proper error message.

    Tomorrow or so I will also take a look at the actual problem here which is the order of inserts when there are foreign key constraints. This should actually be fairly easy to fix because we can just turn off foreign keys during the import and then turn them back on when we're done. This way we only get an error message if there is an actual foreign key problem but not if there is only a transient one during import.

  7. self-assigned this
    on Aug 27, 2018
  8. MKleusberg commented on Aug 28, 2018

    @MKleusberg
    Member

    I believe both issues, the error message and the failing import itself, are fixed now. Can you download tomorrow's nightly build and see if it's working for you as well, @VortixDev? 😄

  9. MKleusberg commented on Sep 28, 2018

    @MKleusberg
    Member

    Did you have a chance to test this yet, @VortixDev?

  10. VortixDev commented on Oct 1, 2018

    @VortixDev
    Author

    @MKleusberg Sorry for the delay in getting back to you! I've done some more testing, and it seems to work much better: I get a "no such table" error when the INSERT runs for a referencing table instead of the "not an error" message.

    As a side note, when I get the error by running the code in the "execute SQL" tab, the error states the line number where the closing bracket is for the CREATE TABLE statement, whilst actually refering to the statement after that, which is the INSERT.

  11. MKleusberg commented on Jun 3, 2020

    @MKleusberg
    Member

    Closing this because it looks like this issue is resolved and we haven't heard back anything for a long time. If there's any remaining problem with this, please just re-open this issue any time 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugConfirmed bugs or reports that are very likely to be bugs.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions