blob: f3261c3b943054ed091bcd57954b8dedac23e59a [file] [log] [blame]
{"version":3,"sources":["webpack:///./src/pages/docs/Miscellaneous/importing-exporting.mdx"],"names":["_frontmatter","layoutProps","MDXLayout","DefaultLayout","MDXContent","components","props","mdxType","parentName","isMDXComponent"],"mappings":"wPAQaA,G,UAAe,S,sOAC5B,IAAMC,EAAc,CAClBD,gBAEIE,EAAYC,IACH,SAASC,EAAT,GAGZ,IAFDC,EAEC,EAFDA,WACGC,EACF,8BACD,OAAO,YAACJ,EAAD,eAAeD,EAAiBK,EAAhC,CAAuCD,WAAYA,EAAYE,QAAQ,cAG5E,iBAAQ,CACN,GAAM,uCADR,uCAGA,gOAEA,uBAAK,gCAAMC,WAAW,OAAU,IAA3B,kpBA2BL,iBAAQ,CACN,GAAM,iCADR,iCAGA,qFACA,uBAAK,gCAAMA,WAAW,OAAU,IAA3B,kCAEL,gEACA,uBAAK,gCAAMA,WAAW,OAAU,IAA3B,gDAEL,+NAEA,gFACA,sBACE,kBAAIA,WAAW,MAAf,QAA6B,sBAAQA,WAAW,MAAnB,wBAA7B,yEACH,sBAAQA,WAAW,MAAnB,UADG,4BACqE,sBAAQA,WAAW,MAAnB,kBADrE,kBAC2I,sBAAQA,WAAW,MAAnB,qBAD3I,sBAGA,kBAAIA,WAAW,MAAf,8CACA,kBAAIA,WAAW,MAAf,SAA8B,sBAAQA,WAAW,MAAnB,qBAA9B,YACA,kBAAIA,WAAW,MAAf,mOAIF,8CAA6B,sBAAQA,WAAW,KAAnB,iCAA7B,8CACA,uBAAK,gCAAMA,WAAW,OAAU,IAA3B,wCAEL,uDAAsC,0BAAYA,WAAW,KAAvB,MAAtC,qCACA,iBAAQ,CACN,GAAM,mCADR,mCAGA,iFACA,uBAAK,gCAAMA,WAAW,OAAU,IAA3B,wDAEL,mEAAkD,sBAAQA,WAAW,KAAnB,QAAlD,OAAkG,sBAAQA,WAAW,KAAnB,OAAlG,oGAEA,uBAAK,gCAAMA,WAAW,OAAU,IAA3B,+CAEL,sCAAqB,sBAAQA,WAAW,KAAnB,MAArB,qJAEA,uBAAK,gCAAMA,WAAW,OAAU,IAA3B,0EAEL,gGAA+E,0BAAYA,WAAW,KAAvB,oBAA/E,2LAGA,2DAA0C,sBAAQA,WAAW,KAAnB,MAA1C,kOAEiE,sBAAQA,WAAW,KAAnB,sBAFjE,aAGA,uBAAK,gCAAMA,WAAW,OAAU,IAA3B,gK,oOAYTJ,EAAWK,gBAAiB","file":"component---src-pages-docs-miscellaneous-importing-exporting-mdx-39fb0cfc0e2237d1999d.js","sourcesContent":["import * as React from 'react'\n /* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\n\nimport DefaultLayout from \"/home/runner/work/superset/superset/docs/node_modules/gatsby-theme-docz/src/base/Layout.js\";\nexport const _frontmatter = {};\nconst layoutProps = {\n _frontmatter\n};\nconst MDXLayout = DefaultLayout;\nexport default function MDXContent({\n components,\n ...props\n}) {\n return <MDXLayout {...layoutProps} {...props} components={components} mdxType=\"MDXLayout\">\n\n\n <h2 {...{\n \"id\": \"importing-and-exporting-datasources\"\n }}>{`Importing and Exporting Datasources`}</h2>\n <p>{`The superset cli allows you to import and export datasources from and to YAML. Datasources include\nboth databases and druid clusters. The data is expected to be organized in the following hierarchy:`}</p>\n <pre><code parentName=\"pre\" {...{}}>{`├──databases\n| ├──database_1\n| | ├──table_1\n| | | ├──columns\n| | | | ├──column_1\n| | | | ├──column_2\n| | | | └──... (more columns)\n| | | └──metrics\n| | | ├──metric_1\n| | | ├──metric_2\n| | | └──... (more metrics)\n| | └── ... (more tables)\n| └── ... (more databases)\n└──druid_clusters\n ├──cluster_1\n | ├──datasource_1\n | | ├──columns\n | | | ├──column_1\n | | | ├──column_2\n | | | └──... (more columns)\n | | └──metrics\n | | ├──metric_1\n | | ├──metric_2\n | | └──... (more metrics)\n | └── ... (more datasources)\n └── ... (more clusters)\n`}</code></pre>\n <h3 {...{\n \"id\": \"exporting-datasources-to-yaml\"\n }}>{`Exporting Datasources to YAML`}</h3>\n <p>{`You can print your current datasources to stdout by running:`}</p>\n <pre><code parentName=\"pre\" {...{}}>{`superset export_datasources\n`}</code></pre>\n <p>{`To save your datasources to a file run:`}</p>\n <pre><code parentName=\"pre\" {...{}}>{`superset export_datasources -f <filename>\n`}</code></pre>\n <p>{`By default, default (null) values will be omitted. Use the -d flag to include them. If you want back\nreferences to be included (e.g. a column to include the table id it belongs to) use the -b flag.`}</p>\n <p>{`Alternatively, you can export datasources using the UI:`}</p>\n <ol>\n <li parentName=\"ol\">{`Open `}<strong parentName=\"li\">{`Sources -> Databases`}</strong>{` to export all tables associated to a single or multiple databases.\n(`}<strong parentName=\"li\">{`Tables`}</strong>{` for one or more tables, `}<strong parentName=\"li\">{`Druid Clusters`}</strong>{` for clusters, `}<strong parentName=\"li\">{`Druid Datasources`}</strong>{` for\ndatasources)`}</li>\n <li parentName=\"ol\">{`Select the items you would like to export.`}</li>\n <li parentName=\"ol\">{`Click `}<strong parentName=\"li\">{`Actions -> Export`}</strong>{` to YAML`}</li>\n <li parentName=\"ol\">{`If you want to import an item that you exported through the UI, you will need to nest it inside\nits parent element, e.g. a database needs to be nested under databases a table needs to be nested\ninside a database element.`}</li>\n </ol>\n <p>{`In order to obtain an `}<strong parentName=\"p\">{`exhaustive list of all fields`}</strong>{` you can import using the YAML import run:`}</p>\n <pre><code parentName=\"pre\" {...{}}>{`superset export_datasource_schema\n`}</code></pre>\n <p>{`As a reminder, you can use the `}<inlineCode parentName=\"p\">{`-b`}</inlineCode>{` flag to include back references.`}</p>\n <h3 {...{\n \"id\": \"importing-datasources-from-yaml\"\n }}>{`Importing Datasources from YAML`}</h3>\n <p>{`In order to import datasources from a YAML file(s), run:`}</p>\n <pre><code parentName=\"pre\" {...{}}>{`superset import_datasources -p <path or filename>\n`}</code></pre>\n <p>{`If you supply a path all files ending with `}<strong parentName=\"p\">{`yaml`}</strong>{` or `}<strong parentName=\"p\">{`yml`}</strong>{` will be parsed. You can apply\nadditional flags (e.g. to search the supplied path recursively):`}</p>\n <pre><code parentName=\"pre\" {...{}}>{`superset import_datasources -p <path> -r\n`}</code></pre>\n <p>{`The sync flag `}<strong parentName=\"p\">{`-s`}</strong>{` takes parameters in order to sync the supplied elements with your file. Be\ncareful this can delete the contents of your meta database. Example:`}</p>\n <pre><code parentName=\"pre\" {...{}}>{`superset import_datasources -p <path / filename> -s columns,metrics\n`}</code></pre>\n <p>{`This will sync all metrics and columns for all datasources found in the `}<inlineCode parentName=\"p\">{`<path /filename>`}</inlineCode>{` in the\nSuperset meta database. This means columns and metrics not specified in YAML will be deleted. If you\nwould add tables to columns,metrics those would be synchronised as well.`}</p>\n <p>{`If you don’t supply the sync flag (`}<strong parentName=\"p\">{`-s`}</strong>{`) importing will only add and update (override) fields.\nE.g. you can add a verbose_name to the column ds in the table random_time_series from the example\ndatasets by saving the following YAML to file and then running the `}<strong parentName=\"p\">{`import_datasources`}</strong>{` command.`}</p>\n <pre><code parentName=\"pre\" {...{}}>{`databases:\n- database_name: main\n tables:\n - table_name: random_time_series\n columns:\n - column_name: ds\n verbose_name: datetime\n`}</code></pre>\n\n </MDXLayout>;\n}\n;\nMDXContent.isMDXComponent = true;\n "],"sourceRoot":""}