blob: 4c6a056cc58942debc060dd1ae394c0196f8628b [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[25],{uOVG:function(e,t,a){"use strict";a.r(t),a.d(t,"_frontmatter",(function(){return c})),a.d(t,"default",(function(){return l}));var n=a("k1TG"),s=a("8o2o"),o=(a("q1tI"),a("7ljp")),r=a("hhGP"),c=(a("qKvR"),{});void 0!==c&&c&&c===Object(c)&&Object.isExtensible(c)&&!c.hasOwnProperty("__filemeta")&&Object.defineProperty(c,"__filemeta",{configurable:!0,value:{name:"_frontmatter",filename:"src/pages/docs/Connecting to Databases/extra-settings.mdx"}});var i={_frontmatter:c},b=r.a;function l(e){var t=e.components,a=Object(s.a)(e,["components"]);return Object(o.b)(b,Object(n.a)({},i,a,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"extra-database-settings"},"Extra Database Settings"),Object(o.b)("h3",{id:"deeper-sqlalchemy-integration"},"Deeper SQLAlchemy Integration"),Object(o.b)("p",null,"It is possible to tweak the database connection information using the parameters exposed by\nSQLAlchemy. In the ",Object(o.b)("strong",{parentName:"p"},"Database edit")," view, you can edit the ",Object(o.b)("strong",{parentName:"p"},"Extra")," field as a JSON blob."),Object(o.b)("p",null,"This JSON string contains extra configuration elements. The ",Object(o.b)("inlineCode",{parentName:"p"},"engine_params")," object gets unpacked\ninto the ",Object(o.b)("inlineCode",{parentName:"p"},"sqlalchemy.create_engine")," call, while the ",Object(o.b)("inlineCode",{parentName:"p"},"metadata_params")," get unpacked into the\n",Object(o.b)("inlineCode",{parentName:"p"},"sqlalchemy.MetaData")," call. Refer to the SQLAlchemy docs for more information."),Object(o.b)("h3",{id:"schemas"},"Schemas"),Object(o.b)("p",null,"Databases like Postgres and Redshift use the ",Object(o.b)("strong",{parentName:"p"},"schema")," as the logical entity on top of the\n",Object(o.b)("strong",{parentName:"p"},"database"),". For Superset to connect to a specific schema, you can set the ",Object(o.b)("strong",{parentName:"p"},"schema")," parameter in\nthe ",Object(o.b)("strong",{parentName:"p"},"Edit Tables")," form (Sources > Tables > Edit record)."),Object(o.b)("h3",{id:"external-password-store-for-sqlalchemy-connections"},"External Password Store for SQLAlchemy Connections"),Object(o.b)("p",null,"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."),Object(o.b)("p",null,"Example: Write a function that takes a single argument of type ",Object(o.b)("inlineCode",{parentName:"p"},"sqla.engine.url")," and returns the\npassword for the given connection string. Then set ",Object(o.b)("inlineCode",{parentName:"p"},"SQLALCHEMY_CUSTOM_PASSWORD_STORE")," in your config\nfile to point to that function."),Object(o.b)("pre",null,Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-python"}),"def example_lookup_password(url):\n secret = <<get password from external framework>>\n return 'secret'\n\nSQLALCHEMY_CUSTOM_PASSWORD_STORE = example_lookup_password\n")),Object(o.b)("p",null,"A common pattern is to use environment variables to make secrets available.\n",Object(o.b)("inlineCode",{parentName:"p"},"SQLALCHEMY_CUSTOM_PASSWORD_STORE")," can also be used for that purpose."),Object(o.b)("pre",null,Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-python"}),"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")),Object(o.b)("h3",{id:"ssl-access-to-databases"},"SSL Access to Databases"),Object(o.b)("p",null,"You can use the ",Object(o.b)("inlineCode",{parentName:"p"},"Extra")," field in the ",Object(o.b)("strong",{parentName:"p"},"Edit Databases")," form to configure SSL:"),Object(o.b)("pre",null,Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-JSON"}),'{\n "metadata_params": {},\n "engine_params": {\n "connect_args":{\n "sslmode":"require",\n "sslrootcert": "/path/to/my/pem"\n }\n }\n}\n')))}void 0!==l&&l&&l===Object(l)&&Object.isExtensible(l)&&!l.hasOwnProperty("__filemeta")&&Object.defineProperty(l,"__filemeta",{configurable:!0,value:{name:"MDXContent",filename:"src/pages/docs/Connecting to Databases/extra-settings.mdx"}}),l.isMDXComponent=!0}}]);
//# sourceMappingURL=component---src-pages-docs-connecting-to-databases-extra-settings-mdx-4a3499cc6b817f177fce.js.map