superset icon indicating copy to clipboard operation
superset copied to clipboard

Databases export/import yaml file bug

Open ibrahimroshdy opened this issue 7 years ago • 5 comments

Superset bug in exporting datasources from the web application, the errors it produces while importing and a simple workaround to whoever needs it.

Exporting the databases list from http://localhost:8088/databaseview/list/ will result in a missing leading key of the databases in the .yaml file.

To reproduce error

  1. Go to http://localhost:8088/databaseview/list/ export_datasource The exported .yaml file from selecting all databases from the list will look like this
- database_name: main
  sqlalchemy_uri: postgresql://superset:XXXXXXXXXX@postgres:5432/superset
  tables: []
- database_name: examples
  sqlalchemy_uri: postgresql://superset:XXXXXXXXXX@postgres:5432/superset
  tables: []
  1. Import datasources to superset (from the docker container or your environment)
superset import_datasources -p <filename>.yaml

result:

2019-10-25 19:54:52,264:INFO:root:Supplied object is not a dictionary.
error_import

Reasons

  • The datasources are not imported correctly

  • The reason is simply because of the leading key in the .yaml file is missing.

  • A bug while generating the .yaml file

Simple fix

  1. Editing .yaml file manually after exporting from the first picture attached
databases:
    - database_name: main
    sqlalchemy_uri: postgresql://superset:XXXXXXXXXX@postgres:5432/superset
    tables: []
    - database_name: examples
    sqlalchemy_uri: postgresql://superset:XXXXXXXXXX@postgres:5432/superset
    tables: []
import_success
  1. Use the export command from terminal, which generates a correct .yaml file
superset export_datasources -p <filename>.yaml

This exports the .yaml correctly with the leading databases key export_success

Environment

Using docker image in the development mode. superset: 0.34.0 python: 3.6 docker: 19.03.4, build 9013bf5

ibrahimroshdy avatar Oct 25 '19 20:10 ibrahimroshdy

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.99. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

issue-label-bot[bot] avatar Oct 25 '19 20:10 issue-label-bot[bot]

I was able to reproduce; @dpgaspar how do you propose we fix this? add the top node databases to the UI export or remove databases from the cli import/export?

villebro avatar Oct 26 '19 10:10 villebro

I suggest you add the top node databases to the UI export. By doing so, the cli import will work just fine.

Also the cli export already adds the top node databases which works just fine on importing, but it exports all the databases list.

ibrahimroshdy avatar Oct 26 '19 10:10 ibrahimroshdy

Hi @ibrahimroshdy, @villebro,

I'll submit a PR to fix this

dpgaspar avatar Oct 30 '19 10:10 dpgaspar

Hi @ibrahimroshdy this is fixed on master now.

dpgaspar avatar Nov 10 '19 16:11 dpgaspar