Bug #95275 import / export from tables not working for csv, json and sql
Submitted: 7 May 2019 9:32 Modified: 7 May 2019 10:10
Reporter: Pero Trenq Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:8.0.16, 8.0.22 OS:Linux ( x86_64)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[7 May 2019 9:32] Pero Trenq
Description:
Export / import buttons in the table view are not working for json, csv (comma delimited) and sql files.

CSV: after exporting to CSV file and reimporting that file, execution fails saying 'list index out of range'

JSON: after exporting to JSON and reimporting that file, all fields are detected properly, and execution "runs" but it imports 0 rows (also says imported 0 rows)

SQL: exporting to SQL requires entering a table name (which is correctly prefilled with the name of the table you're exporting from). But when opening that exported file, all statements begin with "INERT INTO `` ( ...)"; it seems that these "``" should have the table name requested while exporting but it turns out they are just empty, making the exported file useless (read need to do replace INSERT INTO `` with INERT INTO `actual table name` on the whole file before trying to run the statements)

[attached log from last import]

  File "/usr/share/mysql-workbench/libraries/workbench/wizard_page_widget.py", line 97, in go_next
    self.main.go_next_page()
  File "/usr/share/mysql-workbench/libraries/workbench/wizard_form.py", line 76, in go_next_page
    self.pages[index].page_activated(True)
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 186, in page_activated
    self.call_create_preview_table()
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 344, in call_create_preview_table
    self.create_preview_table(self.call_analyze())
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 353, in call_analyze
    if not self.active_module.analyze_file():
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_export_be.py", line 576, in analyze_file
    self._columns[j]['value'].append(col_value)
IndexError: list index out of range
11:04:51 [INF][         Wizard]: Execute 'Prepare Import'
11:04:51 [INF][         Wizard]: Starting thread for 'Import data file'
11:04:51 [ERR][sqlide_power_import_export_be.py:start_import:755]: Row import failed with error: ("Incorrect datetime value: 'None' for column 'deleted_at' at row 1", 1292)...Unhandled exception in Python code: 
Traceback (most recent call last):
  File "/usr/share/mysql-workbench/libraries/workbench/wizard_page_widget.py", line 97, in go_next
    self.main.go_next_page()
  File "/usr/share/mysql-workbench/libraries/workbench/wizard_form.py", line 76, in go_next_page
    self.pages[index].page_activated(True)
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 186, in page_activated
    self.call_create_preview_table()
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 344, in call_create_preview_table
    self.create_preview_table(self.call_analyze())
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 353, in call_analyze
    if not self.active_module.analyze_file():
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_export_be.py", line 576, in analyze_file
    self._columns[j]['value'].append(col_value)
IndexError: list index out of range
11:07:09 [ERR][       pymforms]: Unhandled exception in Python code: 
Traceback (most recent call last):
  File "/usr/share/mysql-workbench/libraries/workbench/wizard_page_widget.py", line 97, in go_next
    self.main.go_next_page()
  File "/usr/share/mysql-workbench/libraries/workbench/wizard_form.py", line 76, in go_next_page
    self.pages[index].page_activated(True)
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 186, in page_activated
    self.call_create_preview_table()
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 344, in call_create_preview_table
    self.create_preview_table(self.call_analyze())
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 353, in call_analyze
    if not self.active_module.analyze_file():
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_export_be.py", line 576, in analyze_file
    self._columns[j]['value'].append(col_value)
IndexError: list index out of range
11:09:35 [ERR][       pymforms]: Unhandled exception in Python code: 
Traceback (most recent call last):
  File "/usr/share/mysql-workbench/libraries/workbench/wizard_page_widget.py", line 97, in go_next
    self.main.go_next_page()
  File "/usr/share/mysql-workbench/libraries/workbench/wizard_form.py", line 76, in go_next_page
    self.pages[index].page_activated(True)
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 186, in page_activated
    self.call_create_preview_table()
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 344, in call_create_preview_table
    self.create_preview_table(self.call_analyze())
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_wizard.py", line 353, in call_analyze
    if not self.active_module.analyze_file():
  File "/usr/lib/mysql-workbench/modules/sqlide_power_import_export_be.py", line 576, in analyze_file
    self._columns[j]['value'].append(col_value)
IndexError: list index out of range

How to repeat:
- create two same tables with different names
- fill fist table with some data
- open a tab and do `select * from first_table`
- click on export button
- select JSON / CSV / SQL
-- SQL: observe the exported file contents (missing table name within the INSERT INTO `` statements)
-- JSON: try to import it to the second table, execution is fine but nothing is imported
-- CSV: try to import it to the second table, execution should fail (at lest for fields containing text with with several new lines)
[7 May 2019 10:10] MySQL Verification Team
Hello Pero Trenq,

Thank you for the report and steps.
Verified as described.

regards,
Umesh
[11 Dec 2019 9:50] Franc Drobnič
Empty table name when exporting to SQL still present in version 8.0.18.

Hope it gets corrected soon.
[21 Apr 2020 13:07] Valentin Gjorgjioski
Affects me on MacOS as well.
[5 Aug 2020 14:03] Alexey Kurasov
Still exists in 8.0.21
[27 Jan 7:01] MySQL Verification Team
Bug #101433 marked as duplicate of this one.