ibrahimroshdy opened a new issue #8453: Databases export/import yaml file bug
URL: https://github.com/apache/incubator-superset/issues/8453
 
 
   ## 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/](url) 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/](url)
   <img width="682" alt="export_datasource" 
src="https://user-images.githubusercontent.com/22573766/67600835-38567280-f773-11e9-89cc-8863834c3e9f.png";>
   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: []
   ```
   
   2. 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.
   >```
   <img width="682" alt="error_import" 
src="https://user-images.githubusercontent.com/22573766/67600577-b7977680-f772-11e9-8862-41de07d5636a.png";>
   
   #### 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: []
   ```
   <img width="684" alt="import_success" 
src="https://user-images.githubusercontent.com/22573766/67601330-5e304700-f774-11e9-805a-211ae91c67eb.png";>
   
   2. 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
   <img width="681" alt="export_success" 
src="https://user-images.githubusercontent.com/22573766/67601797-83718500-f775-11e9-8ab8-64a7a285566b.png";>
   
   ### Environment
   > **Using docker image in the development mode.**
   superset: 0.34.0
   python: 3.6
   docker: 19.03.4, build 9013bf5
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to