blob: 351ad172a3ca4a12fcf2aa6ede05d4338106eb61 [file] [log] [blame]
{"version":3,"sources":["webpack:///./src/pages/docs/Connecting to Databases/extra-settings.mdx"],"names":["_frontmatter","layoutProps","MDXLayout","DefaultLayout","MDXContent","components","props","mdxType","parentName","isMDXComponent"],"mappings":"wPAQaA,G,UAAe,S,2OAC5B,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,2BADR,2BAGA,iBAAQ,CACN,GAAM,iCADR,iCAGA,wIACiB,sBAAQC,WAAW,KAAnB,iBADjB,2BAC8F,sBAAQA,WAAW,KAAnB,SAD9F,0BAEA,oFAAmE,0BAAYA,WAAW,KAAvB,iBAAnE,mCACO,0BAAYA,WAAW,KAAvB,4BADP,oBACgG,0BAAYA,WAAW,KAAvB,mBADhG,2BAEF,0BAAYA,WAAW,KAAvB,uBAFE,6DAGA,iBAAQ,CACN,GAAM,WADR,WAGA,qEAAoD,sBAAQA,WAAW,KAAnB,UAApD,yCACF,sBAAQA,WAAW,KAAnB,YADE,mEAC8G,sBAAQA,WAAW,KAAnB,UAD9G,sBAEE,sBAAQA,WAAW,KAAnB,eAFF,2CAGA,iBAAQ,CACN,GAAM,sDADR,sDAGA,2OAGA,uFAAsE,0BAAYA,WAAW,KAAvB,mBAAtE,wEACiD,0BAAYA,WAAW,KAAvB,oCADjD,oDAGA,uBAAK,gCAAMA,WAAW,OAAU,CAC5B,UAAa,oBADZ,kLAQL,qGACF,0BAAYA,WAAW,KAAvB,oCADE,uCAEA,uBAAK,gCAAMA,WAAW,OAAU,CAC5B,UAAa,oBADZ,4OASL,iBAAQ,CACN,GAAM,2BADR,2BAGA,wCAAuB,0BAAYA,WAAW,KAAvB,SAAvB,iBAA0F,sBAAQA,WAAW,KAAnB,kBAA1F,2BACA,uBAAK,gCAAMA,WAAW,OAAU,CAC5B,UAAa,kBADZ,wM,yOAgBTJ,EAAWK,gBAAiB","file":"component---src-pages-docs-connecting-to-databases-extra-settings-mdx-609360ab941bd90824fc.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\": \"extra-database-settings\"\n }}>{`Extra Database Settings`}</h2>\n <h3 {...{\n \"id\": \"deeper-sqlalchemy-integration\"\n }}>{`Deeper SQLAlchemy Integration`}</h3>\n <p>{`It is possible to tweak the database connection information using the parameters exposed by\nSQLAlchemy. In the `}<strong parentName=\"p\">{`Database edit`}</strong>{` view, you can edit the `}<strong parentName=\"p\">{`Extra`}</strong>{` field as a JSON blob.`}</p>\n <p>{`This JSON string contains extra configuration elements. The `}<inlineCode parentName=\"p\">{`engine_params`}</inlineCode>{` object gets unpacked\ninto the `}<inlineCode parentName=\"p\">{`sqlalchemy.create_engine`}</inlineCode>{` call, while the `}<inlineCode parentName=\"p\">{`metadata_params`}</inlineCode>{` get unpacked into the\n`}<inlineCode parentName=\"p\">{`sqlalchemy.MetaData`}</inlineCode>{` call. Refer to the SQLAlchemy docs for more information.`}</p>\n <h3 {...{\n \"id\": \"schemas\"\n }}>{`Schemas`}</h3>\n <p>{`Databases like Postgres and Redshift use the `}<strong parentName=\"p\">{`schema`}</strong>{` as the logical entity on top of the\n`}<strong parentName=\"p\">{`database`}</strong>{`. For Superset to connect to a specific schema, you can set the `}<strong parentName=\"p\">{`schema`}</strong>{` parameter in\nthe `}<strong parentName=\"p\">{`Edit Tables`}</strong>{` form (Sources > Tables > Edit record).`}</p>\n <h3 {...{\n \"id\": \"external-password-store-for-sqlalchemy-connections\"\n }}>{`External Password Store for SQLAlchemy Connections`}</h3>\n <p>{`Superset can be configured to use an external store for database passwords. This is useful if you a\nrunning a custom secret distribution framework and do not wish to store secrets in Superset’s meta\ndatabase.`}</p>\n <p>{`Example: Write a function that takes a single argument of type `}<inlineCode parentName=\"p\">{`sqla.engine.url`}</inlineCode>{` and returns the\npassword for the given connection string. Then set `}<inlineCode parentName=\"p\">{`SQLALCHEMY_CUSTOM_PASSWORD_STORE`}</inlineCode>{` in your config\nfile to point to that function.`}</p>\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-python\"\n }}>{`def example_lookup_password(url):\n secret = <<get password from external framework>>\n return 'secret'\n\nSQLALCHEMY_CUSTOM_PASSWORD_STORE = example_lookup_password\n`}</code></pre>\n <p>{`A common pattern is to use environment variables to make secrets available.\n`}<inlineCode parentName=\"p\">{`SQLALCHEMY_CUSTOM_PASSWORD_STORE`}</inlineCode>{` can also be used for that purpose.`}</p>\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-python\"\n }}>{`def example_password_as_env_var(url):\n# assuming the uri looks like\n# mysql://localhost?superset_user:{SUPERSET_PASSWORD}\nreturn url.password.format(os.environ)\n\nSQLALCHEMY_CUSTOM_PASSWORD_STORE = example_password_as_env_var\n`}</code></pre>\n <h3 {...{\n \"id\": \"ssl-access-to-databases\"\n }}>{`SSL Access to Databases`}</h3>\n <p>{`You can use the `}<inlineCode parentName=\"p\">{`Extra`}</inlineCode>{` field in the `}<strong parentName=\"p\">{`Edit Databases`}</strong>{` form to configure SSL:`}</p>\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-JSON\"\n }}>{`{\n \"metadata_params\": {},\n \"engine_params\": {\n \"connect_args\":{\n \"sslmode\":\"require\",\n \"sslrootcert\": \"/path/to/my/pem\"\n }\n }\n}\n`}</code></pre>\n\n </MDXLayout>;\n}\n;\nMDXContent.isMDXComponent = true;\n "],"sourceRoot":""}