This page documents the required connection configuration for fully-supported third-party tools.For a list of all supported cluster connection parameters, see the cockroach Connection Parameters.For a list of community-supported third-party tools, see Third-Party Tools Supported by the Community. CockroachDB supports both native drivers and the PostgreSQL wire protocol. Most client drivers and ORM frameworks connect to CockroachDB like they connect to PostgreSQL.
To connect to a CockroachDB Cloud cluster, you need a general connection string or connection parameters, which include the username, host, database, and port. To find these, open the Connect dialog for your cluster in the CockroachDB Cloud Console and select either General connection string or Parameters only as the option.
To connect to a CockroachDB Cloud cluster, you need a general connection string or connection parameters, which include the username, host, database, and port. To find these, open the Connect dialog for your cluster in the CockroachDB Cloud Console and select either General connection string or Parameters only as the option.
To connect to CockroachDB with node-postgres, create a new Client object with a connection string.For example:
const { Client } = require('pg')const client = new Client(process.env.DATABASE_URL)client.connect()
Where DATABASE_URL is an environment variable set to a valid CockroachDB connection string.For more information about connecting with node-postgres, see the official node-postgres documentation.
To connect to CockroachDB with TypeORM, update your project’s DataSource with the required connection properties.For example, suppose that you are defining the DataSource for your application in a file named datasource.ts:
CA_CERT is an environment variable set to the root certificate. You can generate this certificate with cockroach cert create-ca, or you can use a custom CA cert.
CLIENT_KEY is an environment variable set to the client key for the user connecting to the cluster. You can generate this key with cockroach cert create-client.
Where DATABASE_URL is an environment variable set to a valid CockroachDB connection string.For more information about connecting with Prisma, see the official Prisma documentation.
To connect to a CockroachDB Basic or Standard cluster from a Python application, you must have a valid CA certificate located at ~/.postgresql/root.crt.For instructions on downloading a CA certificate from the CockroachDB Cloud Console, see Connect to a CockroachDB Basic Cluster or Connect to a CockroachDB Standard Cluster.
Where DATABASE_URL is an environment variable set to a valid CockroachDB connection string.For more information about connecting with Psycopg, see the official Psycopg documentation.
import psycopgimport oswith psycopg.connect(os.environ['DATABASE_URL']) as conn: # application logic here
Where DATABASE_URL is an environment variable set to a valid CockroachDB connection string.For more information about connecting with Psycopg, see the official Psycopg documentation.
To connect to CockroachDB with SQLAlchemy, create an Engine object by passing the connection string to the create_engine function.For example:
from sqlalchemy import create_engineimport osengine = create_engine(os.environ['DATABASE_URL'])engine.connect()
Where DATABASE_URL is an environment variable set to a valid CockroachDB connection string.
To connect to CockroachDB with SQLAlchemy, you must install the CockroachDB SQLAlchemy adapter.For more information about connecting with SQLAlchemy, see the official SQLAlchemy documentation.In order for SQLAlchemy to use the CockroachDB adapter, the connection string must begin with cockroachdb://. You can use the following code to modify the general connection string, which begins with postgresql://, to the format that works with SQLAlchemy and the CockroachDB adapter:
To connect to CockroachDB with the JDBC driver, create a DataSource object (PGSimpleDataSource or PGPoolingDataSource), and set the connection string with the setUrl class method.For example:
PGSimpleDataSource ds = new PGSimpleDataSource();ds.setUrl(System.getenv("JDBC_DATABASE_URL"));
Where JDBC_DATABASE_URL is an environment variable set to a valid JDBC-compatible CockroachDB connection string.For more information about connecting with JDBC, see the official JDBC documentation.
To connect to CockroachDB with Hibernate ORM, set the object’s hibernate.connection.url property to a valid CockroachDB connection string.For example, if you are bootstrapping your application with a ServiceRegistry object, first read from the Hibernate configuration file, and then set the hibernate.connection.url with the applySetting class method:
To connect to a CockroachDB Basic or Standard cluster from a Ruby application, you must have a valid CA certificate located at ~/.postgresql/root.crt.For instructions on downloading a CA certificate from the CockroachDB Cloud Console, see Connect to a CockroachDB Basic Cluster or Connect to a CockroachDB Standard Cluster.
Where DATABASE_URL is an environment variable set to a valid CockroachDB connection string.For more information about connecting with pg, see the official pg documentation.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"CockroachDB","colors":{"primary":"#9059FF","light":"#9059FF","dark":"#9059FF"},"logo":{"light":"https://mintcdn.com/cockroachlabs/4WvUnbVuGZfqM4kW/images/CockroachLabs_Wordmark_Black.png?fit=max\u0026auto=format\u0026n=4WvUnbVuGZfqM4kW\u0026q=85\u0026s=54ccae625c9986bf1df8ddc7b2c571f0","dark":"https://mintcdn.com/cockroachlabs/4WvUnbVuGZfqM4kW/images/CockroachLabs_Wordmark_White.png?fit=max\u0026auto=format\u0026n=4WvUnbVuGZfqM4kW\u0026q=85\u0026s=0dd9b66973a1c7d3dd72aa67b6094efe","href":"https://www.cockroachlabs.com/"},"favicon":{"light":"https://mintcdn.com/cockroachlabs/2yihO7vMXnL0G_07/images/favicon.svg?fit=max\u0026auto=format\u0026n=2yihO7vMXnL0G_07\u0026q=85\u0026s=01f9aa59c9f275e1f35cd424a27d2551","dark":"https://mintcdn.com/cockroachlabs/2yihO7vMXnL0G_07/images/favicon.svg?fit=max\u0026auto=format\u0026n=2yihO7vMXnL0G_07\u0026q=85\u0026s=01f9aa59c9f275e1f35cd424a27d2551"},"api":{"examples":{"defaults":"required","languages":["curl"]}},"appearance":{"default":"light"},"navbar":{"primary":{"type":"button","label":"Get started free","href":"https://cockroachlabs.cloud/signup?referralId=cc_nav_global\u0026_ga=2.242886210.1147139380.1759903632-41552699.1759903632"}},"footer":{"socials":{"youtube":"https://www.youtube.com/@cockroachdb","x":"https://x.com/CockroachDB","linkedin":"https://www.linkedin.com/company/cockroach-labs/mycompany/verification","instagram":"https://www.instagram.com/cockroachdb"},"links":[{"header":"Product","items":[{"label":"CockroachDB","href":"https://www.cockroachlabs.com/product"},{"label":"CockroachDB Cloud","href":"https://www.cockroachlabs.com/product/cockroachcloud"},{"label":"Compare","href":"https://www.cockroachlabs.com/compare"},{"label":"Pricing","href":"https://www.cockroachlabs.com/pricing"},{"label":"Get CockroachDB","href":"https://www.cockroachlabs.com/get-started-cockroachdb"},{"label":"Sign In","href":"https://cockroachlabs.cloud/"}]},{"header":"Resources","items":[{"label":"Guides","href":"https://resources.cockroachlabs.com/guides"},{"label":"Webinars","href":"https://www.cockroachlabs.com/community/webinars"},{"label":"Videos","href":"https://www.cockroachlabs.com/resources/video"},{"label":"Architecture Overview","href":"https://www.cockroachlabs.com/docs/stable/architecture/overview"},{"label":"FAQ","href":"https://www.cockroachlabs.com/docs/stable/frequently-asked-questions"},{"label":"Security","href":"https://www.cockroachlabs.com/security"}]},{"header":"Learn \u0026 Support","items":[{"label":"Docs","href":"https://www.cockroachlabs.com/docs"},{"label":"University","href":"https://learn.cockroachlabs.com/"},{"label":"Developers","href":"https://www.cockroachlabs.com/developers"},{"label":"Forum","href":"https://forum.cockroachlabs.com/"},{"label":"Slack","href":"https://cockroa.ch/slack"},{"label":"Support Portal","href":"https://support.cockroachlabs.com/hc/en-us"},{"label":"Contact Us","href":"https://www.cockroachlabs.com/contact"}]},{"header":"Company","items":[{"label":"About","href":"https://www.cockroachlabs.com/about"},{"label":"Blog","href":"https://www.cockroachlabs.com/blog"},{"label":"Careers","href":"https://www.cockroachlabs.com/careers"},{"label":"Customers","href":"https://www.cockroachlabs.com/customers"},{"label":"News","href":"https://www.cockroachlabs.com/press"},{"label":"Privacy","href":"https://www.cockroachlabs.com/privacy"},{"label":"Terms of Use","href":"https://www.cockroachlabs.com/website-terms-of-use"}]}]},"fonts":{"heading":{"family":"Poppins"},"body":{"family":"Open Sans"}},"styling":{"eyebrows":"breadcrumbs","codeblocks":{"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}},"latex":true},"integrations":{"gtm":{"tagId":"GTM-NR8LC4"}},"errors":{"404":{"redirect":false,"title":"Page not found","description":"The page you're looking for doesn't exist. [Return to docs home](/index.html)."}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"interaction":{"drilldown":false},"navigation":{"global":{"anchors":[{"anchor":"University","icon":"graduation-cap","href":"https://learn.cockroachlabs.com/"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"cockroachlabs","hasAudioNarration":false,"actualSubdomain":"cockroachlabs","customDomains":["docs.cockroachlabs.com"],"gitSource":{"type":"github","owner":"cockroachlabs","repo":"docs","deployBranch":"main","contentDirectory":"cockroachlabs-preview-main","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af4bb21d7a808c67a4ac795","clientVersion":"0.0.4111","searchFilterCounts":[{"language":"default","tag":"CockroachDB","count":6951},{"language":"default","tag":"Docs","count":3217},{"language":"default","tag":"SQL","count":2566},{"language":"default","tag":"Statements","count":1714},{"language":"default","tag":"Self-Hosted Deployments","count":1457},{"language":"default","tag":"Reference","count":774},{"language":"default","tag":"Cloud Deployments","count":616},{"language":"default","tag":"Endpoints","count":528},{"language":"default","tag":"Cloud API Reference","count":518},{"language":"default","tag":"Get Started","count":441}],"searchSettings":{"isFiltersEnabled":true,"showContentSnippets":true,"fullPageSearch":true}},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":true,"toggles":[],"googleFontsInlined":true},"customCss":[{"filePath":"styles.css","content":":root{--inline-code-bg-light: rgb(var(--gray-200) / 0.92);--inline-code-bg-dark: rgb(255 255 255 / 0.08)}.prose :not(pre)>code{background-color:var(--inline-code-bg-light)!important}.dark .prose :not(pre)>code{background-color:var(--inline-code-bg-dark)!important}@media (min-width: 1536px){#navbar>.max-w-8xl,[class*=\"peer-[.is-not-custom]:peer-[.is-not-center]:max-w-8xl\"]{width:100%!important;max-width:none!important}}#navigation-items{display:flex;flex-direction:column}#navigation-items>ul:not(.sidebar-group){order:1;margin-top:1.5rem}.crdb-metrics-table table{table-layout:fixed!important;width:100%!important;min-width:0!important;max-width:100%!important;border-collapse:collapse}.crdb-metrics-table table td,.crdb-metrics-table table th{min-width:0!important;overflow-wrap:anywhere;word-break:break-word}.crdb-fixed-table table{table-layout:fixed!important;width:100%!important;min-width:0!important;max-width:100%!important;border-collapse:collapse}.crdb-fixed-table table td,.crdb-fixed-table table th{min-width:0!important;overflow-wrap:anywhere;word-break:break-word}.bg-cover{background-size:cover;background-repeat:no-repeat;background-position:center center}.bg-cover__bg-3-1{background-image:url(\"https://cockroach-labs-docs.imgix.net/bg-3-1.png?auto=format,compress\u0026w=1200\u0026q=40\")}.home-header{border-radius:0.5rem;margin-bottom:2rem!important;padding:2rem}.card{border:1px solid #e5e7eb;border-radius:0.75rem;background-color:white}.dark .card{background-color:#0d1117;border-color:rgba(255, 255, 255, 0.1)}.card-link{text-decoration:none!important;overflow:hidden}.card-link:hover{outline:1px solid rgba(105, 51, 255, 0.55);outline-offset:-1px}.card-link,.card-link:hover{transform:none!important;box-shadow:none!important}.card-link a,.card-link a:hover,.card-link h3,.card-link h3:hover,.card-link p,.card-link p:hover{border:0!important;text-decoration:none!important;transform:none!important}.card-link a{display:block;width:100%}.card-link h3{font-size:1rem!important;font-weight:600!important}.card-body{padding:1.5rem}.landing-column-title{margin-bottom:1rem}.overline{text-transform:uppercase;letter-spacing:0.05em}.btn-redirect{display:inline-flex;align-items:center;gap:0.5rem;padding:0.75rem 1.5rem;border:2px solid #e5e7eb;border-radius:0.5rem;text-decoration:none;transition:border-color 0.2s}.btn-redirect:hover{border-color:#6933ff}.btn-block{display:flex;width:100%;justify-content:center}.dark .btn-redirect{border-color:rgba(255, 255, 255, 0.1)}.article-section-title{font-size:1.25rem!important}.article-lists h3{font-size:0.875rem!important;font-weight:600!important;text-transform:uppercase;letter-spacing:0.05em;color:#6b7280!important}.dark .article-lists h3{color:#9ca3af!important}.article-lists ul{font-size:0.875rem}.shadow{box-shadow:0 0.5rem 1rem rgba(0, 0, 0, 0.15)}.bg-dark-wing{background-color:#152849;border-radius:0.5rem}.text-ice-temple{color:#1bf8ec!important;display:inline-flex;align-items:center;gap:0.375rem}.text-ice-temple img{display:inline-block;margin:0}.bg-dark-wing h2{font-size:clamp(1.25rem, 1rem + 1.5vw, 1.75rem)!important}@media (max-width: 576px){.card-body.bg-dark-wing{padding:1.25rem!important}}.text-decoration-none{text-decoration:none!important}.text-muted{color:#6b7280!important}.card-link .card-desc{font-size:0.9375rem!important;font-weight:400!important;line-height:1.5!important;text-align:left!important;color:#4b5563!important;width:100%;margin-top:0.5rem}.dark .card-link .card-desc{color:#9ca3af!important}.report-tag{display:inline-block;padding:0.25rem 0.75rem;border-radius:0.25rem;background-color:rgba(84, 42, 189, 0.08);color:#542abd}.dark .report-tag{background-color:rgba(84, 42, 189, 0.3);color:#b39dff}.resilience-report-img{background-image:url(\"/images/state-resilience.png\");background-size:cover;background-position:center;min-height:150px;border-radius:0.5rem}.row{display:flex!important;flex-wrap:wrap;margin-left:-0.75rem;margin-right:-0.75rem}.display-flex{display:flex!important}.col-lg-4{flex:0 0 auto;width:100%;padding-left:0.75rem;padding-right:0.75rem}@media (min-width: 992px){.col-lg-4{width:33.333333%!important}}.col-lg-3,.col-sm-6,.col-xs-12{flex:0 0 auto;width:100%!important;padding-left:0.75rem;padding-right:0.75rem}@media (min-width: 992px){.col-lg-3{width:25%!important}}@media (min-width: 576px){.col-sm-6{width:50%!important}}.col-12{width:100%!important}.col-lg-12{width:100%;padding-left:0.75rem;padding-right:0.75rem}@media (min-width: 992px){.col-lg-12{width:100%!important}}.col-md-4,.col-md-8{flex:0 0 auto;width:100%;padding-left:0.75rem;padding-right:0.75rem}@media (min-width: 768px){.col-md-4{width:33.333333%!important}.col-md-8{width:66.666667%!important}}.h-100{height:100%}.d-flex{display:flex}.flex-column{flex-direction:column}.mb-3{margin-bottom:1rem!important}.mb-5{margin-bottom:3rem!important}.pb-5{padding-bottom:3rem!important}.mb-xl-5{margin-bottom:3rem!important}.mt-auto{margin-top:auto!important}.mt-0{margin-top:0!important}.mt-2{margin-top:0.5rem!important}.mt-3{margin-top:1rem!important}.mt-5:not(.code-block){margin-top:3rem!important}.code-block.mb-8{margin-bottom:calc(var(--spacing) * 5)}.pt-5{padding-top:3rem!important}.m-0{margin:0!important}.ml-2{margin-left:0.5rem!important}.mb-0{margin-bottom:0!important}.mb-2{margin-bottom:0.5rem!important}.mb-4{margin-bottom:1.5rem!important}.p-2{padding:0.5rem!important}.p-3{padding:1rem!important}.p-4{padding:1.5rem!important}.pb-3{padding-bottom:1rem!important}.pb-4{padding-bottom:1.5rem!important}.ml-1{margin-left:0.25rem!important}.mr-auto{margin-right:auto!important}.justify-content-center{justify-content:center!important}.align-items-center{align-items:center!important}@media (min-width: 1200px){.p-xl-5{padding:3rem!important}}.mx-0{margin-left:0!important;margin-right:0!important}.text-center{text-align:center}.text-white{color:white!important}.text-black{color:black!important}.dark .text-black{color:white!important}.container{width:100%;max-width:1200px;margin-left:auto;margin-right:auto;padding-left:1rem;padding-right:1rem}.card-header-overlap-text{position:relative}@media (min-width: 768px){.p-md-5{padding:3rem!important}}@media (min-width: 992px){.d-lg-flex{display:flex!important}.mb-lg-0{margin-bottom:0!important}}.prose table{border-collapse:collapse!important}.prose table th,.prose table td{border:1px solid rgb(var(--gray-200))!important}.dark .prose table th,.dark .prose table td{border-color:rgb(var(--gray-700) / 0.5)!important}.prose table th{padding:0.571429em;font-weight:600;vertical-align:bottom;color:var(--tw-prose-headings);text-align:left}.prose table th.center-align{text-align:center}.prose table td{padding:0.571429em;vertical-align:baseline}[data-component-part=\"accordion-description\"]{font-size:0.875rem!important}.accordion.mb-3{margin-bottom:0.25rem!important}@media (max-width: 991.98px){[id^=\"kapa-widget-container\"] button{width:36px!important;height:36px!important;min-width:36px!important;padding:0!important;font-size:0!important}[id^=\"kapa-widget-container\"] button svg{width:18px!important;height:18px!important}[id^=\"kapa-widget-container\"] button span{display:none!important}}table.crdb-fixed-table{table-layout:fixed!important;min-width:0!important;width:100%}table.crdb-fixed-table td,table.crdb-fixed-table th{min-width:0!important;overflow-wrap:break-word;word-break:normal}.sql-grammar svg .line{fill:none;stroke:#262626}.sql-grammar svg .bold-line{stroke:#0A0A0A;shape-rendering:crispEdges;stroke-width:2}.sql-grammar svg .thin-line{stroke:#0F0F0F;shape-rendering:crispEdges}.sql-grammar svg .filled{fill:#262626;stroke:none}.sql-grammar svg text.terminal{font-family:Verdana, Sans-serif;font-size:12px;fill:#0A0A0A;font-weight:bold}.sql-grammar svg text.nonterminal{font-family:Verdana, Sans-serif;font-size:12px;fill:#0055FF}.sql-grammar svg text.regexp{font-family:Verdana, Sans-serif;font-size:12px;fill:#0F0F0F}.sql-grammar svg rect,.sql-grammar svg circle,.sql-grammar svg polygon{fill:#262626;stroke:#262626}.sql-grammar svg rect.terminal{fill:#ffffff;stroke:#262626}.sql-grammar svg rect.nonterminal{fill:#FFFFFF;stroke:#262626}.sql-grammar svg rect.text{fill:none;stroke:none}.sql-grammar svg polygon.regexp{fill:#FFFFFF;stroke:#262626}.sql-grammar svg{background-color:#ffffff}.sql-grammar a[name]::before{content:'';display:block;height:80px;margin:-80px 0 0}.sql-grammar a[name]:focus{outline:0}pre[language=\"sql\"][data-crdb-prompt-stripped] code::before{content:\"> \";color:#94e2d5;user-select:none}.mark-yes{color:#008a5e;font-weight:600}.dark .mark-yes{color:#3ddc97}"},{"filePath":"collapse-nav.css","content":"html:not(.crl-nav-off) [data-layout-item=\"sidebar\"] li[data-title]:not([data-active]):not([data-crl-keep])>button+ul,html:not(.crl-nav-off) [data-layout-item=\"mobile-nav\"] li[data-title]:not([data-active]):not([data-crl-keep])>button+ul{display:none}html:not(.crl-nav-off) [data-layout-item=\"sidebar\"] li[data-title]:not([data-active]):not([data-crl-keep])>button svg,html:not(.crl-nav-off) [data-layout-item=\"mobile-nav\"] li[data-title]:not([data-active]):not([data-crl-keep])>button svg{rotate:none!important;transform:none!important}"}],"page":{"pagePath":"docs/v25.1/connect-to-the-database","slug":"/docs/v25.1/connect-to-the-database","pageMetadata":{"title":"Connect to a CockroachDB Cluster","sidebarTitle":"Connect to a Cluster","old_description":"How to connect to a CockroachDB cluster from your application","canonical":"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database","description":null,"href":"/docs/v25.1/connect-to-the-database"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Expandable,Heading,Note,Tab,Table,Tabs}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Tab)_missingMdxReference(`Tab`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tabs)_missingMdxReference(`Tabs`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`This page documents the required connection configuration for `,_jsx(_components.a,{href:`/docs/v25.1/third-party-database-tools`,children:`fully-supported third-party tools`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`For a list of all supported cluster connection parameters, see the `,_jsxs(_components.a,{href:`/docs/v25.1/connection-parameters`,children:[_jsx(_components.code,{children:`cockroach`}),` Connection Parameters`]}),`.`]}),`\n`,_jsxs(_components.p,{children:[`For a list of community-supported third-party tools, see `,_jsx(_components.a,{href:`/docs/v25.1/community-tooling`,children:`Third-Party Tools Supported by the Community`}),`. CockroachDB supports both native drivers and the PostgreSQL wire protocol. Most client drivers and ORM frameworks connect to CockroachDB like they connect to PostgreSQL.`]}),`\n`,_jsx(Heading,{level:`2`,id:`step-1-select-your-deployment`,children:`Step 1. Select your deployment`}),`\n`,_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard`,children:_jsxs(_components.p,{children:[`To connect to a CockroachDB Cloud cluster, you need a general connection string or connection parameters, which include the username, host, database, and port. To find these, open the `,_jsx(_components.strong,{children:`Connect`}),` dialog for your cluster in the `,_jsx(_components.a,{href:`https://cockroachlabs.cloud`,children:`CockroachDB Cloud Console`}),` and select either `,_jsx(_components.strong,{children:`General connection string`}),` or `,_jsx(_components.strong,{children:`Parameters only`}),` as the option.`]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced`,children:_jsxs(_components.p,{children:[`To connect to a CockroachDB Cloud cluster, you need a general connection string or connection parameters, which include the username, host, database, and port. To find these, open the `,_jsx(_components.strong,{children:`Connect`}),` dialog for your cluster in the `,_jsx(_components.a,{href:`https://cockroachlabs.cloud`,children:`CockroachDB Cloud Console`}),` and select either `,_jsx(_components.strong,{children:`General connection string`}),` or `,_jsx(_components.strong,{children:`Parameters only`}),` as the option.`]})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted`,children:[_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster, you need the `,_jsx(_components.a,{href:`/docs/v25.1/connection-parameters#connect-using-a-url`,children:`general connection string`}),` or `,_jsx(_components.a,{href:`/docs/v25.1/connection-parameters#connect-using-discrete-parameters`,children:`connection parameters`}),` for your cluster.`]}),_jsxs(_components.p,{children:[`The connection strings and parameters for your cluster are output when you `,_jsx(_components.a,{href:`/docs/v25.1/cockroach-start#standard-output`,children:`start the cluster`}),`.`]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`step-2-select-your-language-and-driver`,children:`Step 2. Select your language and driver`}),`\n`,_jsxs(Tabs,{children:[_jsx(Tab,{title:`JavaScript/TypeScript`,id:`javascript%2Ftypescript`,\"data-child-tab-ids\":`[\"node-postgres\",\"sequelize\",\"typeorm\",\"prisma\"]`,\"data-child-heading-ids\":`[\"connection-string-format\",\"set-environment-variable\",\"connect-to-the-cluster\",\"connection-string-format-2\",\"set-environment-variable-2\",\"connect-to-the-cluster-2\",\"connection-string-format-3\",\"set-environment-variable-3\",\"connect-to-the-cluster-3\",\"connection-string-format-4\",\"set-environment-variable-4\",\"connect-to-the-cluster-4\"]`,children:_jsxs(Tabs,{children:[_jsxs(Tab,{title:`node-postgres`,id:`node-postgres`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-2\",\"cockroachdb-advanced-2\",\"cockroachdb-self-hosted-2\",\"cockroachdb-basic%2Fstandard-3\",\"cockroachdb-advanced-3\",\"cockroachdb-core\"]`,\"data-child-heading-ids\":`[\"connection-string-format\",\"set-environment-variable\",\"connect-to-the-cluster\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-2`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-2`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-2`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-3`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-3`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`$env:DATABASE_URL = `}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://node-postgres.com`,children:`node-postgres`}),`, create a new `,_jsx(_components.a,{href:`https://node-postgres.com/apis/client`,children:_jsx(_components.code,{children:`Client`})}),` object with a connection string.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`const`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` Client `}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:` =`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` require`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'pg'`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`const`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` client `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#CBA6F7`,\"--shiki-dark-font-weight\":`bold`},children:` new`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` Client`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`DATABASE_URL`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`client`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`connect`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`()`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(_components.p,{children:[`For more information about connecting with node-postgres, see the `,_jsx(_components.a,{href:`https://node-postgres.com/features/connecting`,children:`official node-postgres documentation`}),`.`]})]}),_jsxs(Tab,{title:`Sequelize`,id:`sequelize`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-4\",\"cockroachdb-advanced-4\",\"cockroachdb-self-hosted-3\",\"cockroachdb-basic%2Fstandard-5\",\"cockroachdb-advanced-5\",\"cockroachdb-core-2\"]`,\"data-child-heading-ids\":`[\"connection-string-format-2\",\"set-environment-variable-2\",\"connect-to-the-cluster-2\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-2`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-4`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-4`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-3`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-5`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-5`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-2`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-2`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`$env:DATABASE_URL = `}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-2`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://sequelize.org`,children:`Sequelize`}),`, create a `,_jsx(_components.code,{children:`Sequelize`}),` object with the `,_jsx(_components.a,{href:`https://github.com/cockroachdb/sequelize-cockroachdb`,children:`CockroachDB Sequelize adapter`}),`.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`const`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` Sequelize `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` require`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"sequelize-cockroachdb\"`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`)`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`const`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` connectionString `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`DATABASE_URL`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`const`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` sequelize `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#CBA6F7`,\"--shiki-dark-font-weight\":`bold`},children:` new`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` Sequelize`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(connectionString)`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`To connect to CockroachDB with Sequelize, you must install the `,_jsx(_components.a,{href:`https://github.com/cockroachdb/sequelize-cockroachdb`,children:`CockroachDB Sequelize adapter`}),`.`]}),_jsxs(_components.p,{children:[`For more information about connecting with Sequelize, see the `,_jsx(_components.a,{href:`https://sequelize.org/docs/v6/`,children:`official Sequelize documentation`}),`.`]})]})]}),_jsxs(Tab,{title:`TypeORM`,id:`typeorm`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-6\",\"cockroachdb-advanced-6\",\"cockroachdb-self-hosted-4\",\"cockroachdb-basic%2Fstandard-7\",\"cockroachdb-advanced-7\",\"cockroachdb-core-3\",\"cockroachdb-basic%2Fstandard-8\",\"cockroachdb-advanced-8\",\"cockroachdb-self-hosted-5\"]`,\"data-child-heading-ids\":`[\"connection-string-format-3\",\"set-environment-variable-3\",\"connect-to-the-cluster-3\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-3`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-6`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(_components.p,{children:[`TypeORM configures SSL separately in the DataSource object (`,_jsx(_components.code,{children:`ssl: true`}),`).`]})]}),_jsxs(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-6`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsx(_components.p,{children:`TypeORM configures SSL separately in the DataSource object:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`ssl`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` ca`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`CA_CERT`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`CA_CERT`}),` is an environment variable set to the root certificate `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-4`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsx(_components.p,{children:`TypeORM configures SSL separately in the DataSource object:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`ssl`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` ca`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`CA_CERT`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` key`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`CLIENT_KEY`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` cert`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`CLIENT_CERT`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-7`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-7`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-3`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-3`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`$env:DATABASE_URL = `}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-3`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://typeorm.io`,children:`TypeORM`}),`, update your project’s `,_jsx(_components.a,{href:`https://typeorm.io/data-source`,children:_jsx(_components.code,{children:`DataSource`})}),` with the required connection properties.`]}),_jsxs(_components.p,{children:[`For example, suppose that you are defining the `,_jsx(_components.code,{children:`DataSource`}),` for your application in a file named `,_jsx(_components.code,{children:`datasource.ts`}),`:`]}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-8`,children:_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` const`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` AppDataSource `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#CBA6F7`,\"--shiki-dark-font-weight\":`bold`},children:` new`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` DataSource`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` type`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` \"cockroachdb\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` url`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`DATABASE_URL`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` ssl`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:` true`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:` ...`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`)`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`;`})]}),`\n`]})})})}),_jsxs(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-8`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` const`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` AppDataSource `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#CBA6F7`,\"--shiki-dark-font-weight\":`bold`},children:` new`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` DataSource`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` type`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` \"cockroachdb\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` url`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`DATABASE_URL`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` ssl`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` ca`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`CA_CERT`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:` ...`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`)`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`;`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`CA_CERT`}),` is an environment variable set to the root certificate `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-5`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` const`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` AppDataSource `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-light-font-weight\":`bold`,\"--shiki-dark\":`#CBA6F7`,\"--shiki-dark-font-weight\":`bold`},children:` new`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` DataSource`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` type`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` \"cockroachdb\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` url`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`DATABASE_URL`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` ssl`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` ca`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`CA_CERT`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` key`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`CLIENT_KEY`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` cert`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` process`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`env`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`CLIENT_CERT`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:` ...`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`)`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`;`})]}),`\n`]})})}),_jsx(_components.p,{children:`Where:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`CA_CERT`}),` is an environment variable set to the root certificate. You can generate this certificate with `,_jsx(_components.a,{href:`/docs/v25.1/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/v25.1/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`CLIENT_KEY`}),` is an environment variable set to the `,_jsx(_components.a,{href:`/docs/v25.1/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster. You can generate this key with `,_jsx(_components.a,{href:`/docs/v25.1/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`CLIENT_CERT`}),` is an environment variable set to the `,_jsx(_components.a,{href:`/docs/v25.1/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster. You can generate this certificate with `,_jsx(_components.a,{href:`/docs/v25.1/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]}),_jsxs(_components.p,{children:[`You can then import the `,_jsx(_components.code,{children:`AppDataSource`}),` into any file in your project and call `,_jsx(_components.code,{children:`AppDataSource.initialize()`}),` to connect to CockroachDB:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`AppDataSource`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`initialize`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:` .`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`then`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`async`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` ()`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:` =>`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#9399B2`,\"--shiki-dark-font-style\":`italic`},children:` // Execute operations`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` }`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`)`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`;`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`For more information about connecting with TypeORM, see the `,_jsx(_components.a,{href:`https://typeorm.io/#/`,children:`official TypeORM documentation`}),`.`]})]}),_jsxs(Tab,{title:`Prisma`,id:`prisma`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-9\",\"cockroachdb-advanced-9\",\"cockroachdb-self-hosted-6\",\"cockroachdb-basic%2Fstandard-10\",\"cockroachdb-advanced-10\",\"cockroachdb-core-4\"]`,\"data-child-heading-ids\":`[\"connection-string-format-4\",\"set-environment-variable-4\",\"connect-to-the-cluster-4\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-4`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-9`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-9`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-6`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-10`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-10`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-4`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-4`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`$env:DATABASE_URL = `}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-4`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://prisma.io/`,children:`Prisma`}),`, set the `,_jsx(_components.code,{children:`url`}),` field of the `,_jsx(_components.code,{children:`datasource`}),` block in your Prisma schema to your database connection URL:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`generator client `}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` provider `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` \"prisma-client-js\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`datasource db `}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` provider `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` \"cockroachdb\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` url `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` env`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"DATABASE_URL\"`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`model Widget `}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` id String `}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`@`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`id `}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`@`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`default`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`(`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`dbgenerated`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"gen_random_uuid()\"`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`))`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:` @db`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`Uuid`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(_components.p,{children:[`For more information about connecting with Prisma, see the `,_jsx(_components.a,{href:`https://www.prisma.io/cockroachdb`,children:`official Prisma documentation`}),`.`]})]})]})}),_jsxs(Tab,{title:`Python`,id:`python`,\"data-child-tab-ids\":`[\"psycopg2\",\"psycopg3\",\"sqlalchemy\",\"django\"]`,\"data-child-heading-ids\":`[\"connection-string-format-5\",\"set-environment-variable-5\",\"connect-to-the-cluster-5\",\"connection-string-format-6\",\"set-environment-variable-6\",\"connect-to-the-cluster-6\",\"connection-string-format-7\",\"set-environment-variable-7\",\"connect-to-the-cluster-7\",\"connection-string-format-8\",\"connect-to-the-cluster-8\"]`,children:[_jsxs(Note,{children:[_jsxs(_components.p,{children:[`To connect to a CockroachDB Basic or Standard cluster from a Python application, you must have a valid CA certificate located at `,_jsx(_components.code,{children:`~/.postgresql/root.crt`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on downloading a CA certificate from the CockroachDB Cloud Console, see `,_jsx(_components.a,{href:`https://www.cockroachlabs.com/docs/cockroachcloud/connect-to-a-basic-cluster`,children:`Connect to a CockroachDB Basic Cluster`}),` or `,_jsx(_components.a,{href:`https://www.cockroachlabs.com/docs/cockroachcloud/connect-to-your-cluster`,children:`Connect to a CockroachDB Standard Cluster`}),`.`]})]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Psycopg2`,id:`psycopg2`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-11\",\"cockroachdb-advanced-11\",\"cockroachdb-self-hosted-7\",\"cockroachdb-basic%2Fstandard-12\",\"cockroachdb-advanced-12\",\"cockroachdb-core-5\"]`,\"data-child-heading-ids\":`[\"connection-string-format-5\",\"set-environment-variable-5\",\"connect-to-the-cluster-5\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-5`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-11`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-11`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-7`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-12`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-12`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-5`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-5`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F38BA8`,\"--shiki-dark-font-style\":`italic`},children:`set`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` DATABASE_URL={connection`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` string}`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-5`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://www.psycopg.org`,children:`Psycopg2`}),`, pass a connection string to the `,_jsxs(_components.a,{href:`https://www.psycopg.org/docs/connection.html`,children:[_jsx(_components.code,{children:`psycopg2.connect`}),` function`]}),`.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` psycopg2`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`conn `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` psycopg2`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`connect`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#EBA0AC`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#EBA0AC`,\"--shiki-dark-font-style\":`italic`},children:`environ`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`[`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#A6E3A1`,\"--shiki-dark-font-style\":`italic`},children:`DATABASE_URL`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`])`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(_components.p,{children:[`For more information about connecting with Psycopg, see the `,_jsx(_components.a,{href:`https://www.psycopg.org/docs`,children:`official Psycopg documentation`}),`.`]})]}),_jsxs(Tab,{title:`Psycopg3`,id:`psycopg3`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-13\",\"cockroachdb-advanced-13\",\"cockroachdb-self-hosted-8\",\"cockroachdb-basic%2Fstandard-14\",\"cockroachdb-advanced-14\",\"cockroachdb-core-6\"]`,\"data-child-heading-ids\":`[\"connection-string-format-6\",\"set-environment-variable-6\",\"connect-to-the-cluster-6\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-6`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-13`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-13`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-8`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-14`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-14`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-6`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-6`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F38BA8`,\"--shiki-dark-font-style\":`italic`},children:`set`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` DATABASE_URL={connection`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` string}`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-6`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://www.psycopg.org`,children:`Psycopg3`}),`, pass a connection string to the `,_jsxs(_components.a,{href:`https://www.psycopg.org/psycopg3/docs/basic/usage.html`,children:[_jsx(_components.code,{children:`psycopg.connect`}),` function`]}),`.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` psycopg`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`with`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` psycopg`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`connect`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#EBA0AC`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#EBA0AC`,\"--shiki-dark-font-style\":`italic`},children:`environ`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`[`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#A6E3A1`,\"--shiki-dark-font-style\":`italic`},children:`DATABASE_URL`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`])`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` as`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` conn`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#9399B2`,\"--shiki-dark-font-style\":`italic`},children:` # application logic here`})}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(_components.p,{children:[`For more information about connecting with Psycopg, see the `,_jsx(_components.a,{href:`https://www.psycopg.org/psycopg3/docs/basic/index.html`,children:`official Psycopg documentation`}),`.`]})]}),_jsxs(Tab,{title:`SQLAlchemy`,id:`sqlalchemy`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-15\",\"cockroachdb-advanced-15\",\"cockroachdb-self-hosted-9\",\"cockroachdb-basic%2Fstandard-16\",\"cockroachdb-advanced-16\",\"cockroachdb-core-7\"]`,\"data-child-heading-ids\":`[\"connection-string-format-7\",\"set-environment-variable-7\",\"connect-to-the-cluster-7\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-7`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-15`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`cockroachdb://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-15`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`cockroachdb://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-9`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`cockroachdb://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-16`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-16`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-7`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-7`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F38BA8`,\"--shiki-dark-font-style\":`italic`},children:`set`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` DATABASE_URL={connection`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` string}`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-7`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`http://docs.sqlalchemy.org/`,children:`SQLAlchemy`}),`, `,_jsxs(_components.a,{href:`https://docs.sqlalchemy.org/core/engines.html`,children:[`create an `,_jsx(_components.code,{children:`Engine`}),` object`]}),` by passing the connection string to the `,_jsx(_components.code,{children:`create_engine`}),` function.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`from`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` sqlalchemy `}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` create_engine`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`engine `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:` create_engine`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#EBA0AC`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#EBA0AC`,\"--shiki-dark-font-style\":`italic`},children:`environ`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`[`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#A6E3A1`,\"--shiki-dark-font-style\":`italic`},children:`DATABASE_URL`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`])`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`engine`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`connect`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`To connect to CockroachDB with SQLAlchemy, you must install the `,_jsx(_components.a,{href:`https://github.com/cockroachdb/sqlalchemy-cockroachdb`,children:`CockroachDB SQLAlchemy adapter`}),`.`]}),_jsxs(_components.p,{children:[`For more information about connecting with SQLAlchemy, see the `,_jsx(_components.a,{href:`https://docs.sqlalchemy.org/core/engines_connections.html`,children:`official SQLAlchemy documentation`}),`.`]}),_jsxs(_components.p,{children:[`In order for SQLAlchemy to use the CockroachDB adapter, the connection string must begin with `,_jsx(_components.code,{children:`cockroachdb://`}),`. You can use the following code to modify the general connection string, which begins with `,_jsx(_components.code,{children:`postgresql://`}),`, to the format that works with SQLAlchemy and the CockroachDB adapter:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`engine `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:` create_engine`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#EBA0AC`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#EBA0AC`,\"--shiki-dark-font-style\":`italic`},children:`environ`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`[`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#A6E3A1`,\"--shiki-dark-font-style\":`italic`},children:`DATABASE_URL`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`].`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`replace`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"postgresql://\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` \"cockroachdb://\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`engine`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`connect`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`})]}),`\n`]})})})]})]}),_jsxs(Tab,{title:`Django`,id:`django`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-17\",\"cockroachdb-advanced-17\",\"cockroachdb-core-8\",\"cockroachdb-basic%2Fstandard-18\",\"cockroachdb-advanced-18\",\"cockroachdb-self-hosted-10\"]`,\"data-child-heading-ids\":`[\"connection-string-format-8\",\"connect-to-the-cluster-8\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-8`,children:`Connection string format`}),_jsxs(_components.p,{children:[`Django does not use a connection string. Instead, you configure connection parameters in the `,_jsx(_components.code,{children:`DATABASES`}),` property in your project’s `,_jsx(_components.code,{children:`settings.py`}),` file.`]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-17`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-17`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-8`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-8`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB from a `,_jsx(_components.a,{href:`https://www.djangoproject.com`,children:`Django`}),` application, update the `,_jsx(_components.code,{children:`DATABASES`}),` property in the project’s `,_jsx(_components.code,{children:`settings.py`}),` file.`]}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-18`,children:_jsx(CodeBlock,{filename:``,numberOfLines:`19`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`19`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#9399B2`,\"--shiki-dark-font-style\":`italic`},children:`## settings.py`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`...`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`DATABASES `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'default'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'ENGINE'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'django_cockroachdb'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'NAME'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{database}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'USER'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{username}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'PASSWORD'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{password}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'HOST'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{host}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'PORT'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{port}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'OPTIONS'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'sslmode'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'verify-full'`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`...`})}),`\n`]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-18`,children:_jsx(CodeBlock,{filename:``,numberOfLines:`20`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`20`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#9399B2`,\"--shiki-dark-font-style\":`italic`},children:`## settings.py`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`...`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`DATABASES `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'default'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'ENGINE'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'django_cockroachdb'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'NAME'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{database}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'USER'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{username}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'PASSWORD'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{password}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'HOST'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{host}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'PORT'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{port}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'OPTIONS'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'sslmode'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'verify-full'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'sslrootcert'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`path`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`expandvars`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'{root-cert}'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`...`})}),`\n`]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-10`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`21`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`21`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#9399B2`,\"--shiki-dark-font-style\":`italic`},children:`## settings.py`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`...`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`DATABASES `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'default'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'ENGINE'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'django_cockroachdb'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'NAME'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{database}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'USER'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{username}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'HOST'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{host}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'PORT'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` '`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:`{port}`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'OPTIONS'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'sslmode'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'verify-full'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'sslrootcert'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`path`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`expandvars`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'{root-cert}'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'sslcert'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`path`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`expandvars`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'{client-cert}'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'sslkey'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`:`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`path`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`expandvars`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'{client-key}'`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`...`})}),`\n`]})})}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`To connect to CockroachDB with Django, you must install the `,_jsx(_components.a,{href:`https://github.com/cockroachdb/django-cockroachdb`,children:`CockroachDB Django adapter`}),`.`]}),_jsxs(_components.p,{children:[`For more information about connecting with Django, see the `,_jsx(_components.a,{href:`https://docs.djangoproject.com/en/4.0/`,children:`official Django documentation`}),`.`]})]})]})]})]}),_jsx(Tab,{title:`Go`,id:`go`,\"data-child-tab-ids\":`[\"pgx\",\"pq\",\"gorm\"]`,\"data-child-heading-ids\":`[\"connection-string-format-9\",\"set-environment-variable-8\",\"connect-to-the-cluster-9\",\"connection-string-format-10\",\"set-environment-variable-9\",\"connect-to-the-cluster-10\",\"connection-string-format-11\",\"set-environment-variable-10\",\"connect-to-the-cluster-11\"]`,children:_jsxs(Tabs,{children:[_jsxs(Tab,{title:`pgx`,id:`pgx`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-19\",\"cockroachdb-advanced-19\",\"cockroachdb-self-hosted-11\",\"cockroachdb-basic%2Fstandard-20\",\"cockroachdb-advanced-20\",\"cockroachdb-core-9\"]`,\"data-child-heading-ids\":`[\"connection-string-format-9\",\"set-environment-variable-8\",\"connect-to-the-cluster-9\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-9`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-19`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-19`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-11`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-20`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-20`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-9`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-8`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F38BA8`,\"--shiki-dark-font-style\":`italic`},children:`set`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` DATABASE_URL={connection`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` string}`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-9`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://github.com/jackc/pgx`,children:`pgx`}),`, use the `,_jsx(_components.code,{children:`pgx.Connect`}),` function.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`go`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`go`,children:_jsxs(_components.code,{language:`go`,numberOfLines:`17`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`package`}),_jsx(_components.span,{style:{color:`#F9E2AF`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F9E2AF`,\"--shiki-dark-font-style\":`italic`},children:` main`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` (`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"context\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"log\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"os\"`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"github.com/jackc/pgx/v4\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`func`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` main`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`\tconn`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` err `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:=`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` pgx`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Connect`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`context`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Background`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(),`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Getenv`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"DATABASE_URL\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`\tif`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` err `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`!=`}),_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-dark\":`#F38BA8`},children:` nil`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`\t\tlog`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Fatal`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`err`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`\t}`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`\tdefer`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` conn`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Close`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`context`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Background`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`())`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`]})})}),_jsxs(_components.p,{children:[`For more information about connecting with pgx, see the `,_jsx(_components.a,{href:`https://pkg.go.dev/github.com/jackc/pgx`,children:`official pgx documentation`}),`.`]})]}),_jsxs(Tab,{title:`pq`,id:`pq`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-21\",\"cockroachdb-advanced-21\",\"cockroachdb-self-hosted-12\",\"cockroachdb-basic%2Fstandard-22\",\"cockroachdb-advanced-22\",\"cockroachdb-core-10\"]`,\"data-child-heading-ids\":`[\"connection-string-format-10\",\"set-environment-variable-9\",\"connect-to-the-cluster-10\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-10`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-21`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-21`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-12`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-22`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-22`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-10`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-9`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F38BA8`,\"--shiki-dark-font-style\":`italic`},children:`set`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` DATABASE_URL={connection`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` string}`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-10`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://godoc.org/github.com/lib/pq`,children:`pq`}),`, use the `,_jsxs(_components.a,{href:`https://go.dev/doc/tutorial/database-access`,children:[_jsx(_components.code,{children:`sql.Open`}),` function`]}),`.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`go`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`go`,children:_jsxs(_components.code,{language:`go`,numberOfLines:`17`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`package`}),_jsx(_components.span,{style:{color:`#F9E2AF`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F9E2AF`,\"--shiki-dark-font-style\":`italic`},children:` main`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` (`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"database/sql\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"log\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"os\"`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`\t_ `}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"github.com/lib/pq\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`func`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` main`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`\tdb`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` err `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:=`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` sql`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Open`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"postgres\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Getenv`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"DATABASE_URL\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`\tif`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` err `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`!=`}),_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-dark\":`#F38BA8`},children:` nil`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`\t\tlog`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Fatal`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`err`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`\t}`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`\tdefer`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` db`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Close`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`]})})}),_jsxs(_components.p,{children:[`For more information about connecting with pq, see the `,_jsx(_components.a,{href:`https://pkg.go.dev/github.com/lib/pq`,children:`official pq documentation`}),`.`]})]}),_jsxs(Tab,{title:`GORM`,id:`gorm`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-23\",\"cockroachdb-advanced-23\",\"cockroachdb-self-hosted-13\",\"cockroachdb-basic%2Fstandard-24\",\"cockroachdb-advanced-24\",\"cockroachdb-core-11\"]`,\"data-child-heading-ids\":`[\"connection-string-format-11\",\"set-environment-variable-10\",\"connect-to-the-cluster-11\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-11`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-23`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-23`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-13`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-24`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-24`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-11`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-10`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F38BA8`,\"--shiki-dark-font-style\":`italic`},children:`set`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` DATABASE_URL={connection`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` string}`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-11`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`http://gorm.io`,children:`GORM`}),`, use the `,_jsx(_components.code,{children:`gorm.Open`}),` function, with the GORM `,_jsx(_components.code,{children:`postgres`}),` driver.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`16`,language:`go`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`go`,children:_jsxs(_components.code,{language:`go`,numberOfLines:`16`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`package`}),_jsx(_components.span,{style:{color:`#F9E2AF`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F9E2AF`,\"--shiki-dark-font-style\":`italic`},children:` main`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`import`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` (`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"log\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"os\"`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"gorm.io/driver/postgres\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\t\"gorm.io/gorm\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`func`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` main`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`\tdb`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` err `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:=`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` gorm`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Open`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`postgres`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Open`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`os`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Getenv`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"DATABASE_URL\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)),`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#F9E2AF`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F9E2AF`,\"--shiki-dark-font-style\":`italic`},children:`gorm`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#F9E2AF`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F9E2AF`,\"--shiki-dark-font-style\":`italic`},children:`Config`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`{})`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`\tif`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` err `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`!=`}),_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-dark\":`#F38BA8`},children:` nil`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`\t\tlog`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`Fatal`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`err`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`\t}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`}`})}),`\n`]})})}),_jsxs(_components.p,{children:[`For more information about connecting with GORM, see the `,_jsx(_components.a,{href:`https://gorm.io/docs`,children:`official GORM documentation`}),`.`]})]})]})}),_jsx(Tab,{title:`Java`,id:`java`,\"data-child-tab-ids\":`[\"jdbc\",\"hibernate\"]`,\"data-child-heading-ids\":`[\"connection-string-format-12\",\"set-environment-variable-11\",\"connect-to-the-cluster-12\",\"connection-string-format-13\",\"set-environment-variable-12\",\"connect-to-the-cluster-13\"]`,children:_jsxs(Tabs,{children:[_jsxs(Tab,{title:`JDBC`,id:`jdbc`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-25\",\"cockroachdb-advanced-25\",\"cockroachdb-self-hosted-14\",\"cockroachdb-basic%2Fstandard-26\",\"cockroachdb-advanced-26\",\"cockroachdb-core-12\"]`,\"data-child-heading-ids\":`[\"connection-string-format-12\",\"set-environment-variable-11\",\"connect-to-the-cluster-12\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-12`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-25`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`jdbc:postgresql://{host}:{port}/{database}?password={password}\u0026sslmode=verify-full\u0026user={username}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-25`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`jdbc:postgresql://{host}:{port}/{database}?user={username}\u0026password={password}\u0026sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-14`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`jdbc:postgresql://{host}:{port}/{database}?user={username}\u0026sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-26`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-26`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`https://wikipedia.org/wiki/Percent-encoding`,children:`URL-encoded`}),` path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-12`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`https://wikipedia.org/wiki/Percent-encoding`,children:`URL-encoded`}),` path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`https://wikipedia.org/wiki/Percent-encoding`,children:`URL-encoded`}),` path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`https://wikipedia.org/wiki/Percent-encoding`,children:`URL-encoded`}),` path to the `,_jsx(_components.a,{href:`https://tools.ietf.org/html/rfc5208`,children:`PKCS#8`}),`-formatted `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client --also-generate-pkcs8-key`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-11`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`JDBC_DATABASE_URL`}),` environment variable to your JDBC connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` JDBC_DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`$env:JDBC_DATABASE_URL = `}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-12`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with the `,_jsx(_components.a,{href:`https://jdbc.postgresql.org`,children:`JDBC`}),` driver, create a `,_jsx(_components.code,{children:`DataSource`}),` object (`,_jsxs(_components.a,{href:`https://jdbc.postgresql.org/documentation/datasource/#applications-datasource`,children:[_jsx(_components.code,{children:`PGSimpleDataSource`}),` or `,_jsx(_components.code,{children:`PGPoolingDataSource`})]}),`), and set the connection string with the `,_jsx(_components.code,{children:`setUrl`}),` class method.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`java`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`java`,children:_jsxs(_components.code,{language:`java`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`PGSimpleDataSource`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` ds `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` new`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` PGSimpleDataSource`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`ds`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`setUrl`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`System`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`getenv`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"JDBC_DATABASE_URL\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`));`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`JDBC_DATABASE_URL`}),` is an environment variable set to a valid JDBC-compatible CockroachDB connection string.`]}),_jsxs(_components.p,{children:[`For more information about connecting with JDBC, see the `,_jsx(_components.a,{href:`https://jdbc.postgresql.org/documentation/`,children:`official JDBC documentation`}),`.`]})]}),_jsxs(Tab,{title:`Hibernate`,id:`hibernate`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-27\",\"cockroachdb-advanced-27\",\"cockroachdb-self-hosted-15\",\"cockroachdb-basic%2Fstandard-28\",\"cockroachdb-advanced-28\",\"cockroachdb-core-13\"]`,\"data-child-heading-ids\":`[\"connection-string-format-13\",\"set-environment-variable-12\",\"connect-to-the-cluster-13\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-13`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-27`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`jdbc:postgresql://{host}:{port}/{database}?password={password}\u0026sslmode=verify-full\u0026user={username}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-27`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`jdbc:postgresql://{host}:{port}/{database}?user={username}\u0026password={password}\u0026sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-15`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`jdbc:postgresql://{host}:{port}/{database}?user={username}\u0026sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-28`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-28`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`https://wikipedia.org/wiki/Percent-encoding`,children:`URL-encoded`}),` path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-13`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`https://wikipedia.org/wiki/Percent-encoding`,children:`URL-encoded`}),` path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`https://wikipedia.org/wiki/Percent-encoding`,children:`URL-encoded`}),` path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`https://wikipedia.org/wiki/Percent-encoding`,children:`URL-encoded`}),` path to the `,_jsx(_components.a,{href:`https://tools.ietf.org/html/rfc5208`,children:`PKCS#8`}),`-formatted `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client --also-generate-pkcs8-key`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-12`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`JDBC_DATABASE_URL`}),` environment variable to your JDBC connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` JDBC_DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`$env:JDBC_DATABASE_URL = `}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-13`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://hibernate.org/orm`,children:`Hibernate`}),` ORM, set the object’s `,_jsx(_components.code,{children:`hibernate.connection.url`}),` property to a valid CockroachDB connection string.`]}),_jsxs(_components.p,{children:[`For example, if you are bootstrapping your application with a `,_jsx(_components.a,{href:`https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#bootstrap-native-registry`,children:_jsx(_components.code,{children:`ServiceRegistry`})}),` object, first read from the Hibernate configuration file, and then set the `,_jsx(_components.code,{children:`hibernate.connection.url`}),` with the `,_jsx(_components.code,{children:`applySetting`}),` class method:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`java`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`java`,children:_jsxs(_components.code,{language:`java`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`StandardServiceRegistry`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` standardRegistry `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` new`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` StandardServiceRegistryBuilder`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` .`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`configure`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` \"hibernate.cfg.xml\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` ).`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`applySetting`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"hibernate.connection.url\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`,`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` System`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`getenv`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"JDBC_DATABASE_URL\"`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` .`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`build`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`Metadata`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` metadata `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` new`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` MetadataSources`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` standardRegistry `}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` .`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`getMetadataBuilder`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` .`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`build`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`SessionFactory`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` sessionFactory `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` metadata`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`getSessionFactoryBuilder`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:` .`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`build`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`();`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`JDBC_DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`To connect to CockroachDB with Hibernate, you must specify the `,_jsx(_components.a,{href:`/docs/v25.1/install-client-drivers?filters=java#hibernate`,children:`CockroachDB Hibernate dialect`}),` in your `,_jsx(_components.code,{children:`hibernate.cfg.xml`}),` configuration file.`]}),_jsxs(_components.p,{children:[`For more information about connecting with Hibernate, see the `,_jsx(_components.a,{href:`https://hibernate.org/orm/documentation`,children:`official Hibernate documentation`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`Ruby`,id:`ruby`,\"data-child-tab-ids\":`[\"pg\",\"active-record\"]`,\"data-child-heading-ids\":`[\"connection-string-format-14\",\"set-environment-variable-13\",\"connect-to-the-cluster-14\",\"connection-string-format-15\",\"set-environment-variable-14\",\"connect-to-the-cluster-15\"]`,children:[_jsxs(Note,{children:[_jsxs(_components.p,{children:[`To connect to a CockroachDB Basic or Standard cluster from a Ruby application, you must have a valid CA certificate located at `,_jsx(_components.code,{children:`~/.postgresql/root.crt`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on downloading a CA certificate from the CockroachDB Cloud Console, see `,_jsx(_components.a,{href:`https://www.cockroachlabs.com/docs/cockroachcloud/connect-to-a-basic-cluster`,children:`Connect to a CockroachDB Basic Cluster`}),` or `,_jsx(_components.a,{href:`https://www.cockroachlabs.com/docs/cockroachcloud/connect-to-your-cluster`,children:`Connect to a CockroachDB Standard Cluster`}),`.`]})]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`pg`,id:`pg`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-29\",\"cockroachdb-advanced-29\",\"cockroachdb-self-hosted-16\",\"cockroachdb-basic%2Fstandard-30\",\"cockroachdb-advanced-30\",\"cockroachdb-core-14\"]`,\"data-child-heading-ids\":`[\"connection-string-format-14\",\"set-environment-variable-13\",\"connect-to-the-cluster-14\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-14`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-29`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-29`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-16`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`postgresql://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-30`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-30`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-14`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-13`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F38BA8`,\"--shiki-dark-font-style\":`italic`},children:`set`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` DATABASE_URL={connection`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` string}`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-14`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with the `,_jsx(_components.a,{href:`https://rubygems.org/gems/pg`,children:`Ruby pg`}),` driver, use the `,_jsx(_components.code,{children:`PG.connect`}),` function.`]}),_jsx(_components.p,{children:`For example:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`ruby`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`ruby`,children:_jsxs(_components.code,{language:`ruby`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#9399B2`,\"--shiki-dark-font-style\":`italic`},children:`#!/usr/bin/env ruby`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`require`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` 'pg'`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`conn `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#F9E2AF`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F9E2AF`,\"--shiki-dark-font-style\":`italic`},children:` PG`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`.`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:`connect`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`(`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`ENV`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`[`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'DATABASE_URL'`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`]`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-dark\":`#9399B2`},children:`)`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(_components.p,{children:[`For more information about connecting with pg, see the `,_jsx(_components.a,{href:`https://www.rubydoc.info/gems/pg`,children:`official pg documentation`}),`.`]})]}),_jsxs(Tab,{title:`Active Record`,id:`active-record`,\"data-child-tab-ids\":`[\"cockroachdb-basic%2Fstandard-31\",\"cockroachdb-advanced-31\",\"cockroachdb-self-hosted-17\",\"cockroachdb-basic%2Fstandard-32\",\"cockroachdb-advanced-32\",\"cockroachdb-core-15\"]`,\"data-child-heading-ids\":`[\"connection-string-format-15\",\"set-environment-variable-14\",\"connect-to-the-cluster-15\"]`,children:[_jsx(Heading,{level:`3`,id:`connection-string-format-15`,children:`Connection string format`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-31`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`cockroachdb://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-31`,children:_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`cockroachdb://{username}:{password}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`CockroachDB self-hosted`,id:`cockroachdb-self-hosted-17`,children:[_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`cockroachdb://{username}@{host}:{port}/{database}?sslmode=verify-full\u0026sslrootcert={root-cert}\u0026sslcert={client-cert}\u0026sslkey={client-key}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v25.1/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})]}),_jsx(Expandable,{title:`Connection parameters`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`CockroachDB Basic/Standard`,id:`cockroachdb-basic%2Fstandard-32`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]})]})]})}),_jsx(Tab,{title:`CockroachDB Advanced`,id:`cockroachdb-advanced-32`,children:_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{password}`})}),_jsx(_components.td,{children:`The password for the SQL user connecting to the cluster.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate that you `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication#node-identity-verification`,children:`downloaded from the CockroachDB Cloud Console`}),`.`]})]})]})]})}),_jsxs(Tab,{title:`CockroachDB Core`,id:`cockroachdb-core-15`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{username}`})}),_jsxs(_components.td,{children:[`The `,_jsx(_components.a,{href:`/docs/stable/security-reference/authorization#sql-users`,children:`SQL user`}),` connecting to the cluster.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{host}`})}),_jsx(_components.td,{children:`The host on which the CockroachDB node is running.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{port}`})}),_jsx(_components.td,{children:`The port at which the CockroachDB node is listening.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{database}`})}),_jsx(_components.td,{children:`The name of the (existing) database.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{root-cert}`})}),_jsxs(_components.td,{children:[`The path to the root certificate.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-ca`})}),`, or you can use a `,_jsx(_components.a,{href:`/docs/stable/create-security-certificates-custom-ca`,children:`custom CA cert`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-cert}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client certificate`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this certificate with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`{client-key}`})}),_jsxs(_components.td,{children:[`The path to the `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#client-key-and-certificates`,children:`client key`}),` for the user connecting to the cluster.`,_jsx(`br`,{}),`You can generate this key with `,_jsx(_components.a,{href:`/docs/stable/cockroach-cert#subcommands`,children:_jsx(_components.code,{children:`cockroach cert create-client`})}),`.`]})]})]})]}),_jsxs(_components.p,{children:[`The connection information shown on this page uses `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`client certificate and key authentication`}),` to connect to a secure, CockroachDB self-hosted cluster.`]}),_jsxs(_components.p,{children:[`To connect to a CockroachDB self-hosted cluster with client certificate and key authentication, you must first `,_jsx(_components.a,{href:`/docs/cockroachcloud/authentication`,children:`generate server and client certificates`}),`.`]}),_jsxs(_components.p,{children:[`For instructions on starting a secure cluster, see `,_jsx(_components.a,{href:`/docs/v26.2/secure-a-cluster`,children:`Start a Local Cluster (Secure)`}),`.`]})]})]})}),_jsx(Heading,{level:`3`,id:`set-environment-variable-14`,children:`Set environment variable`}),_jsxs(_components.p,{children:[`Set a `,_jsx(_components.code,{children:`DATABASE_URL`}),` environment variable to your connection string:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac or Linux`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`export`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` DATABASE_URL`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`\"{connection string}\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F38BA8`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F38BA8`,\"--shiki-dark-font-style\":`italic`},children:`set`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` DATABASE_URL={connection`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` string}`})]}),`\n`]})})})]}),_jsx(Heading,{level:`3`,id:`connect-to-the-cluster-15`,children:`Connect to the cluster`}),_jsxs(_components.p,{children:[`To connect to CockroachDB with `,_jsx(_components.a,{href:`https://github.com/rails/rails/tree/main/activerecord`,children:`Active Record`}),` from a Rails app, update the database configuration in `,_jsx(_components.code,{children:`config/database.yml`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`yaml`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`yaml`,children:_jsxs(_components.code,{language:`yaml`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:`default`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#F5C2E7`,\"--shiki-dark\":`#F5C2E7`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#F9E2AF`,\"--shiki-dark\":`#F9E2AF`},children:`default`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:` adapter`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` cockroachdb`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-dark\":`#89B4FA`},children:` url`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`:`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:` \u003c%= ENV['DATABASE_URL'] %>`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`...`})}),`\n`]})})}),_jsxs(_components.p,{children:[`Where `,_jsx(_components.code,{children:`DATABASE_URL`}),` is an environment variable set to a valid CockroachDB connection string.`]}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`To connect to CockroachDB with Active Record, you must install the `,_jsx(_components.a,{href:`https://rubygems.org/gems/activerecord-cockroachdb-adapter`,children:`Active Record CockroachDB adapter`}),`.`]}),_jsxs(_components.p,{children:[`For more information about connecting with Active Record, see the `,_jsx(_components.a,{href:`https://guides.rubyonrails.org/active_record_querying.html`,children:`official Active Record documentation`}),`.`]})]})]})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`see-also`,children:`See also`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/docs/v25.1/install-client-drivers`,children:`Install a Driver or ORM Framework`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/docs/v25.1/connection-pooling`,children:`Connection Pooling`})}),`\n`,_jsx(_components.li,{children:_jsxs(_components.a,{href:`/docs/v25.1/connection-parameters`,children:[_jsx(_components.code,{children:`cockroach`}),` Connection Parameters`]})}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}},"config":{},"pageMetadata":{"title":"Connect to a CockroachDB Cluster","sidebarTitle":"Connect to a Cluster","old_description":"How to connect to a CockroachDB cluster from your application","canonical":"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database","description":null,"href":"/docs/v25.1/connect-to-the-database"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Step 1. Select your deployment","slug":"step-1-select-your-deployment","depth":2,"children":[]},{"title":"Step 2. Select your language and driver","slug":"step-2-select-your-language-and-driver","depth":2,"children":[{"title":"Connection string format","slug":"connection-string-format","depth":3,"children":[],"tabId":"node-postgres"},{"title":"Set environment variable","slug":"set-environment-variable","depth":3,"children":[],"tabId":"node-postgres"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster","depth":3,"children":[],"tabId":"node-postgres"},{"title":"Connection string format","slug":"connection-string-format-2","depth":3,"children":[],"tabId":"sequelize"},{"title":"Set environment variable","slug":"set-environment-variable-2","depth":3,"children":[],"tabId":"sequelize"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-2","depth":3,"children":[],"tabId":"sequelize"},{"title":"Connection string format","slug":"connection-string-format-3","depth":3,"children":[],"tabId":"typeorm"},{"title":"Set environment variable","slug":"set-environment-variable-3","depth":3,"children":[],"tabId":"typeorm"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-3","depth":3,"children":[],"tabId":"typeorm"},{"title":"Connection string format","slug":"connection-string-format-4","depth":3,"children":[],"tabId":"prisma"},{"title":"Set environment variable","slug":"set-environment-variable-4","depth":3,"children":[],"tabId":"prisma"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-4","depth":3,"children":[],"tabId":"prisma"},{"title":"Connection string format","slug":"connection-string-format-5","depth":3,"children":[],"tabId":"psycopg2"},{"title":"Set environment variable","slug":"set-environment-variable-5","depth":3,"children":[],"tabId":"psycopg2"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-5","depth":3,"children":[],"tabId":"psycopg2"},{"title":"Connection string format","slug":"connection-string-format-6","depth":3,"children":[],"tabId":"psycopg3"},{"title":"Set environment variable","slug":"set-environment-variable-6","depth":3,"children":[],"tabId":"psycopg3"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-6","depth":3,"children":[],"tabId":"psycopg3"},{"title":"Connection string format","slug":"connection-string-format-7","depth":3,"children":[],"tabId":"sqlalchemy"},{"title":"Set environment variable","slug":"set-environment-variable-7","depth":3,"children":[],"tabId":"sqlalchemy"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-7","depth":3,"children":[],"tabId":"sqlalchemy"},{"title":"Connection string format","slug":"connection-string-format-8","depth":3,"children":[],"tabId":"django"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-8","depth":3,"children":[],"tabId":"django"},{"title":"Connection string format","slug":"connection-string-format-9","depth":3,"children":[],"tabId":"pgx"},{"title":"Set environment variable","slug":"set-environment-variable-8","depth":3,"children":[],"tabId":"pgx"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-9","depth":3,"children":[],"tabId":"pgx"},{"title":"Connection string format","slug":"connection-string-format-10","depth":3,"children":[],"tabId":"pq"},{"title":"Set environment variable","slug":"set-environment-variable-9","depth":3,"children":[],"tabId":"pq"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-10","depth":3,"children":[],"tabId":"pq"},{"title":"Connection string format","slug":"connection-string-format-11","depth":3,"children":[],"tabId":"gorm"},{"title":"Set environment variable","slug":"set-environment-variable-10","depth":3,"children":[],"tabId":"gorm"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-11","depth":3,"children":[],"tabId":"gorm"},{"title":"Connection string format","slug":"connection-string-format-12","depth":3,"children":[],"tabId":"jdbc"},{"title":"Set environment variable","slug":"set-environment-variable-11","depth":3,"children":[],"tabId":"jdbc"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-12","depth":3,"children":[],"tabId":"jdbc"},{"title":"Connection string format","slug":"connection-string-format-13","depth":3,"children":[],"tabId":"hibernate"},{"title":"Set environment variable","slug":"set-environment-variable-12","depth":3,"children":[],"tabId":"hibernate"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-13","depth":3,"children":[],"tabId":"hibernate"},{"title":"Connection string format","slug":"connection-string-format-14","depth":3,"children":[],"tabId":"pg"},{"title":"Set environment variable","slug":"set-environment-variable-13","depth":3,"children":[],"tabId":"pg"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-14","depth":3,"children":[],"tabId":"pg"},{"title":"Connection string format","slug":"connection-string-format-15","depth":3,"children":[],"tabId":"active-record"},{"title":"Set environment variable","slug":"set-environment-variable-14","depth":3,"children":[],"tabId":"active-record"},{"title":"Connect to the cluster","slug":"connect-to-the-cluster-15","depth":3,"children":[],"tabId":"active-record"}]},{"title":"See also","slug":"see-also","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/cockroachlabs/4695317e415d4eba/kapa.js","/_mintlify/custom/cockroachlabs/40fb45a3cfe42c92/copy-code-prompt.js","/_mintlify/custom/cockroachlabs/3f343c9e8c40397a/collapse-nav.js"],"subdomain":"cockroachlabs","siteName":"CockroachDB","title":"Connect to a CockroachDB Cluster - CockroachDB","navMaps":{"firstHrefInVersion":{"v26.4":{"href":"/docs/stable/connect-to-the-database","matchLevel":1},"v26.3":{"href":"/docs/v26.3/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v26.2":{"href":"/docs/v26.2/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v26.1":{"href":"/docs/v26.1/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v25.4":{"href":"/docs/v25.4/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v25.3":{"href":"/docs/v25.3/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v25.2":{"href":"/docs/v25.2/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v25.1":{"href":"/docs/v25.1/connect-to-the-database","matchLevel":0},"v24.3":{"href":"/docs/v24.3/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v24.1":{"href":"/docs/v24.1/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v23.2":{"href":"/docs/v23.2/connect-to-the-database","matchLevel":1,"canonicalOverride":true},"v23.1":{"href":"/docs/v23.1/connect-to-the-database","matchLevel":1,"canonicalOverride":true}},"firstHrefInLanguage":{}},"lastModified":"2026-11-11T19:16:09.674Z","originalFileLocation":"docs/v25.1/connect-to-the-database.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"light\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"CockroachDB\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Connect to a CockroachDB Cluster - CockroachDB\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"CockroachDB\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://cockroachlabs.mintlify.site/_mintlify/api/og/v2?division=Connect+to+an+Application\u0026amp;title=Connect+to+a+CockroachDB+Cluster\u0026amp;theme=4aeed7318cb28bd50868adb3\u0026amp;signature=57fd6e1941fd1b4abef268fc559f300448bf92e8fe36a8a5744931c9857acb34\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Connect to a CockroachDB Cluster - CockroachDB\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://cockroachlabs.mintlify.site/_mintlify/api/og/v2?division=Connect+to+an+Application\u0026amp;title=Connect+to+a+CockroachDB+Cluster\u0026amp;theme=4aeed7318cb28bd50868adb3\u0026amp;signature=57fd6e1941fd1b4abef268fc559f300448bf92e8fe36a8a5744931c9857acb34\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"CockroachDB\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#9059FF\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/v25.1/connect-to-the-database.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.cockroachlabs.com/#organization\",\"name\":\"CockroachDB\",\"url\":\"https://docs.cockroachlabs.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/cockroachlabs/4WvUnbVuGZfqM4kW/images/CockroachLabs_Wordmark_Black.png?fit=max\u0026auto=format\u0026n=4WvUnbVuGZfqM4kW\u0026q=85\u0026s=54ccae625c9986bf1df8ddc7b2c571f0\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.cockroachlabs.com#website\",\"name\":\"CockroachDB\",\"url\":\"https://docs.cockroachlabs.com\",\"publisher\":{\"@id\":\"https://docs.cockroachlabs.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database#webpage\",\"url\":\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database\",\"name\":\"Connect to a CockroachDB Cluster\",\"dateModified\":\"2026-11-11T19:16:09.674Z\",\"isPartOf\":{\"@id\":\"https://docs.cockroachlabs.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Connect to an Application\",\"item\":\"https://docs.cockroachlabs.com/docs/v25.1/install-client-drivers\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Connect to a CockroachDB Cluster\",\"item\":\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database#article\",\"headline\":\"Connect to a CockroachDB Cluster\",\"name\":\"Connect to a CockroachDB Cluster\",\"url\":\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database\",\"mainEntityOfPage\":{\"@id\":\"https://docs.cockroachlabs.com/docs/stable/connect-to-the-database#webpage\"},\"dateModified\":\"2026-11-11T19:16:09.674Z\",\"publisher\":{\"@id\":\"https://docs.cockroachlabs.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.cockroachlabs.com#website\"}}]}\u003c/script>","agentPointerHref":"/docs/v25.1/connect-to-the-database.md","siteName":"CockroachDB","nav":{"global":{"anchors":[{"anchor":"University","icon":"graduation-cap","href":"https://learn.cockroachlabs.com/"}]},"products":[{"product":"Cockroach Continuum Cloud","icon":"https://mintlify.s3.us-west-1.amazonaws.com/cockroachlabs/images/continuum/cockroachlabs-symbol.svg","description":"The agentic database cloud","pages":[{"title":"Cockroach Continuum Cloud","href":"/docs/continuum"}]},{"product":"CockroachDB","icon":"database","description":"Distributed SQL database","versions":[{"version":"v26.4","default":true,"tag":"Stable","pages":[{"title":"v26.4","href":"/docs/stable/connect-to-the-database"}]},{"version":"v26.3","pages":[{"title":"v26.3","href":"/docs/v26.3/connect-to-the-database"}]},{"version":"v26.2","pages":[{"title":"v26.2","href":"/docs/v26.2/connect-to-the-database"}]},{"version":"v26.1","pages":[{"title":"v26.1","href":"/docs/v26.1/connect-to-the-database"}]},{"version":"v25.4","tag":"LTS","pages":[{"title":"v25.4","href":"/docs/v25.4/connect-to-the-database"}]},{"version":"v25.3","tag":"Unsupported","pages":[{"title":"v25.3","href":"/docs/v25.3/connect-to-the-database"}]},{"version":"v25.2","tag":"LTS","pages":[{"title":"v25.2","href":"/docs/v25.2/connect-to-the-database"}]},{"version":"v25.1","tag":"Unsupported","tabs":[{"tab":"Docs","icon":"book-open","pages":[{"title":"CockroachDB Docs","sidebarTitle":"Docs Home","href":"/docs/v25.1"},{"group":"Get Started","pages":[{"group":"Install CockroachDB","pages":[{"title":"Install CockroachDB on Mac","href":"/docs/v25.1/install-cockroachdb-mac"},{"title":"Install CockroachDB on Linux","href":"/docs/v25.1/install-cockroachdb-linux"},{"title":"Install a FIPS-ready CockroachDB Runtime","href":"/docs/v25.1/fips"},{"title":"Install CockroachDB on Windows","href":"/docs/v25.1/install-cockroachdb-windows"}]},{"group":"Develop with CockroachDB","pages":[{"title":"Developer Basics","href":"/docs/v25.1/developer-basics"},{"group":"JavaScript/TypeScript","pages":[{"title":"Build a Simple CRUD Node.js App with CockroachDB and the node-postgres Driver","href":"/docs/v25.1/build-a-nodejs-app-with-cockroachdb"},{"title":"Build a Node.js App with CockroachDB and Sequelize","href":"/docs/v25.1/build-a-nodejs-app-with-cockroachdb-sequelize"},{"title":"Build a Simple CRUD Node.js App with CockroachDB and Knex.js","href":"/docs/v25.1/build-a-nodejs-app-with-cockroachdb-knexjs"},{"title":"Build a Simple CRUD Node.js App with CockroachDB and Prisma","href":"/docs/v25.1/build-a-nodejs-app-with-cockroachdb-prisma"},{"title":"Build a TypeScript App with CockroachDB and TypeORM","href":"/docs/v25.1/build-a-typescript-app-with-cockroachdb"}]},{"group":"Python","pages":[{"title":"Build a Python App with CockroachDB and Psycopg 3","href":"/docs/v25.1/build-a-python-app-with-cockroachdb-psycopg3"},{"title":"Build a Python App with CockroachDB and psycopg2","href":"/docs/v25.1/build-a-python-app-with-cockroachdb"},{"title":"Build a Simple CRUD Python App with CockroachDB and SQLAlchemy","href":"/docs/v25.1/build-a-python-app-with-cockroachdb-sqlalchemy"},{"title":"Build a Python App with CockroachDB and Django","href":"/docs/v25.1/build-a-python-app-with-cockroachdb-django"},{"title":"Build a Python App with CockroachDB and asyncpg","href":"/docs/v25.1/build-a-python-app-with-cockroachdb-asyncpg"}]},{"group":"Golang","pages":[{"title":"Build a Simple CRUD Go App with CockroachDB and the Go pgx Driver","href":"/docs/v25.1/build-a-go-app-with-cockroachdb"},{"title":"Build a Go App with CockroachDB and GORM","href":"/docs/v25.1/build-a-go-app-with-cockroachdb-gorm"},{"title":"Build a Go App with CockroachDB the Go pq Driver","href":"/docs/v25.1/build-a-go-app-with-cockroachdb-pq"},{"title":"Build a Go App with CockroachDB and upper/db","href":"/docs/v25.1/build-a-go-app-with-cockroachdb-upperdb"}]},{"group":"Java","pages":[{"title":"Build a Simple CRUD Java App with CockroachDB and JDBC","href":"/docs/v25.1/build-a-java-app-with-cockroachdb"},{"title":"Build a Java App with CockroachDB and Hibernate","href":"/docs/v25.1/build-a-java-app-with-cockroachdb-hibernate"},{"title":"Build a Java App with CockroachDB and jOOQ","href":"/docs/v25.1/build-a-java-app-with-cockroachdb-jooq"},{"title":"Build a Spring App with CockroachDB and MyBatis","href":"/docs/v25.1/build-a-spring-app-with-cockroachdb-mybatis"},{"title":"Build a Spring App with CockroachDB and JDBC","href":"/docs/v25.1/build-a-spring-app-with-cockroachdb-jdbc"},{"title":"Build a Spring App with CockroachDB and JPA","href":"/docs/v25.1/build-a-spring-app-with-cockroachdb-jpa"}]},{"group":"Ruby","pages":[{"title":"Build a Ruby App with CockroachDB and the Ruby pg Driver","href":"/docs/v25.1/build-a-ruby-app-with-cockroachdb"},{"title":"Build a Ruby App with CockroachDB and Active Record","href":"/docs/v25.1/build-a-ruby-app-with-cockroachdb-activerecord"}]},{"title":"Build a C# App with CockroachDB and the .NET Npgsql Driver","sidebarTitle":"C# (.NET)","href":"/docs/v25.1/build-a-csharp-app-with-cockroachdb"},{"title":"Build a Rust App with CockroachDB and the Rust-Postgres Driver","sidebarTitle":"Rust","href":"/docs/v25.1/build-a-rust-app-with-cockroachdb"},{"title":"Build a GraphQL Application Using Hasura","sidebarTitle":"Hasura (GraphQL)","href":"/docs/v25.1/hasura-getting-started"}]},{"group":"Standard Examples","pages":[{"title":"Create and Deploy an AWS Lambda Function Built on CockroachDB","sidebarTitle":"AWS Lambda","href":"/docs/v25.1/deploy-lambda-function"},{"title":"Deploy a CockroachDB Cloud Application with Google Cloud Run","sidebarTitle":"Google Cloud Run","href":"/docs/v25.1/deploy-app-gcr"},{"title":"Deploy a Netlify App Built on CockroachDB","sidebarTitle":"Netlify","href":"/docs/v25.1/deploy-app-netlify"},{"title":"Deploy a Web App Built on CockroachDB with Vercel","sidebarTitle":"Vercel","href":"/docs/v25.1/deploy-app-vercel"},{"title":"Serverless Function Best Practices","href":"/docs/v25.1/serverless-function-best-practices"}]},{"title":"MovR","href":"/docs/v25.1/movr"}]},{"group":"CockroachDB and AI","pages":[{"title":"CockroachDB Docs MCP Server","sidebarTitle":"Docs MCP Server","href":"/docs/v25.1/docs-mcp-integration"}]},{"group":"Feature Overview","pages":[{"group":"CockroachDB Basics","pages":[{"title":"Why CockroachDB?","href":"/docs/v25.1/why-cockroachdb"},{"title":"Replication and Rebalancing","sidebarTitle":"Replication \u0026 Rebalancing","href":"/docs/v25.1/demo-replication-and-rebalancing"},{"title":"CockroachDB Resilience Demo","sidebarTitle":"CockroachDB Resilience","href":"/docs/v25.1/demo-cockroachdb-resilience"},{"title":"Serializable Transactions","href":"/docs/v25.1/demo-serializable"},{"title":"Multi-Active Availability","href":"/docs/v25.1/multi-active-availability"}]},{"group":"CockroachDB SQL","pages":[{"title":"PostgreSQL Compatibility","href":"/docs/v25.1/postgresql-compatibility"},{"title":"SQL Feature Support in CockroachDB","sidebarTitle":"SQL Features","href":"/docs/v25.1/sql-feature-support"},{"title":"SQL FAQs","href":"/docs/v25.1/sql-faqs"}]}]},{"group":"Data Resilience","pages":[{"title":"Data Resilience","sidebarTitle":"Overview","href":"/docs/v25.1/data-resilience"},{"title":"Disaster Recovery Overview","sidebarTitle":"Disaster Recovery","href":"/docs/v25.1/disaster-recovery-overview"}]},{"group":"Connect to an Application","pages":[{"title":"Install a Driver or ORM Framework","description":null,"href":"/docs/v25.1/install-client-drivers"},{"title":"Connect to a CockroachDB Cluster","sidebarTitle":"Connect to a Cluster","href":"/docs/v25.1/connect-to-the-database"},{"title":"Client Connection Parameters","description":null,"href":"/docs/v25.1/connection-parameters"},{"title":"Connection Pooling","href":"/docs/v25.1/connection-pooling"}]},{"group":"Self-Hosted Deployments","pages":[{"title":"Production Checklist","href":"/docs/v25.1/recommended-production-settings"},{"title":"Deployment \u0026 Operations Skills Taxonomy","sidebarTitle":"Deployment and Operations Skills Taxonomy","href":"/docs/v25.1/deployment-operations-skills-taxonomy"},{"group":"Deploy Locally","pages":[{"group":"Deploy from Binary","pages":[{"title":"Deploy a Local Cluster from Binary (Secure)","href":"/docs/v25.1/secure-a-cluster"},{"title":"Deploy a Local Cluster from Binary (Insecure)","href":"/docs/v25.1/start-a-local-cluster"}]},{"title":"Deploy a Local Cluster in Docker (Insecure)","href":"/docs/v25.1/start-a-local-cluster-in-docker"},{"group":"Deploy in Kubernetes","pages":[{"title":"Deploy a Local Cluster in Kubernetes","href":"/docs/v25.1/orchestrate-a-local-cluster-with-kubernetes"},{"title":"Orchestration with Kubernetes (Insecure)","href":"/docs/v25.1/orchestrate-a-local-cluster-with-kubernetes-insecure"}]},{"title":"Simulate a Multi-Region Cluster on localhost (Insecure)","sidebarTitle":"Simulate a Multi-Region Cluster Locally","href":"/docs/v25.1/simulate-a-multi-region-cluster-on-localhost"}]},{"group":"Deploy Manually","pages":[{"title":"Manual Deployment","sidebarTitle":"Overview","href":"/docs/v25.1/manual-deployment"},{"title":"Deploy CockroachDB On-Premises","sidebarTitle":"Deploy On-Premises","href":"/docs/v25.1/deploy-cockroachdb-on-premises"},{"title":"Deploy CockroachDB On-Premises (Insecure)","href":"/docs/v25.1/deploy-cockroachdb-on-premises-insecure"},{"title":"Deploy CockroachDB on AWS EC2","sidebarTitle":"Deploy on AWS","href":"/docs/v25.1/deploy-cockroachdb-on-aws"},{"title":"Deploy CockroachDB on AWS EC2 (Insecure)","href":"/docs/v25.1/deploy-cockroachdb-on-aws-insecure"},{"title":"Deploy CockroachDB on Microsoft Azure","sidebarTitle":"Deploy on Azure","href":"/docs/v25.1/deploy-cockroachdb-on-microsoft-azure"},{"title":"Deploy CockroachDB on Microsoft Azure (Insecure)","href":"/docs/v25.1/deploy-cockroachdb-on-microsoft-azure-insecure"},{"title":"Deploy CockroachDB on Google Cloud Platform GCE","sidebarTitle":"Deploy on Google Cloud Platform GCE","href":"/docs/v25.1/deploy-cockroachdb-on-google-cloud-platform"},{"title":"Deploy CockroachDB on Google Cloud Platform GCE (Insecure)","href":"/docs/v25.1/deploy-cockroachdb-on-google-cloud-platform-insecure"},{"title":"Deploy CockroachDB on Digital Ocean","sidebarTitle":"Deploy on Digital Ocean","href":"/docs/v25.1/deploy-cockroachdb-on-digital-ocean"},{"title":"Deploy CockroachDB on Digital Ocean (Insecure)","href":"/docs/v25.1/deploy-cockroachdb-on-digital-ocean-insecure"}]},{"group":"Deploy on Kubernetes with Legacy Technologies","pages":[{"title":"Kubernetes Overview","sidebarTitle":"Overview","href":"/docs/v25.1/kubernetes-overview"},{"title":"Deploy CockroachDB in a Single Kubernetes Cluster","href":"/docs/v25.1/deploy-cockroachdb-with-kubernetes"},{"title":"Deploy CockroachDB in a Single Kubernetes Cluster (Insecure)","href":"/docs/v25.1/deploy-cockroachdb-with-kubernetes-insecure"},{"title":"Deploy CockroachDB on Red Hat OpenShift","sidebarTitle":"OpenShift Deployment","href":"/docs/v25.1/deploy-cockroachdb-with-kubernetes-openshift"},{"title":"Orchestrate CockroachDB Across Multiple Kubernetes Clusters","sidebarTitle":"Multi-Cluster Deployment","href":"/docs/v25.1/orchestrate-cockroachdb-with-kubernetes-multi-cluster"},{"group":"Operate on Kubernetes","pages":[{"title":"Pod Scheduling","href":"/docs/v25.1/schedule-cockroachdb-kubernetes"},{"title":"Resource Management","href":"/docs/v25.1/configure-cockroachdb-kubernetes"},{"title":"Certificate Management","href":"/docs/v25.1/secure-cockroachdb-kubernetes"},{"title":"Cluster Scaling","href":"/docs/v25.1/scale-cockroachdb-kubernetes"},{"title":"Cluster Monitoring","href":"/docs/v25.1/monitor-cockroachdb-kubernetes"},{"title":"Upgrade a cluster in Kubernetes","sidebarTitle":"Cluster Upgrades","href":"/docs/v25.1/upgrade-cockroachdb-kubernetes"},{"title":"CockroachDB Performance on Kubernetes","sidebarTitle":"Kubernetes Performance","href":"/docs/v25.1/kubernetes-performance"}]}]},{"group":"Multi-Region for Self-Hosted Deployments","pages":[{"title":"Topology Patterns Overview","href":"/docs/v25.1/topology-patterns"},{"title":"Basic Production Topology","href":"/docs/v25.1/topology-basic-production"},{"title":"Follower Reads Topology","href":"/docs/v25.1/topology-follower-reads"},{"title":"Follow-the-Workload Topology","href":"/docs/v25.1/topology-follow-the-workload"},{"title":"Regional Tables","href":"/docs/v25.1/regional-tables"},{"title":"Global Tables","href":"/docs/v25.1/global-tables"}]},{"group":"Security","pages":[{"group":"Certificates","pages":[{"title":"Use the CockroachDB CLI to provision a development cluster","href":"/docs/v25.1/manage-certs-cli"},{"title":"Manage PKI certificates with HashiCorp Vault","href":"/docs/v25.1/manage-certs-vault"},{"title":"Create Security Certificates using OpenSSL","href":"/docs/v25.1/create-security-certificates-openssl"},{"title":"Advanced Public Key Infrastructure (PKI) Certificate Scenarios","href":"/docs/v25.1/create-security-certificates-custom-ca"},{"title":"Using Online Certificate Status Protocol (OCSP) with CockroachDB","sidebarTitle":"Use Online Certificate Status Protocol (OCSP)","href":"/docs/v25.1/manage-certs-revoke-ocsp"},{"title":"Certificate-based authentication using multiple values from the X.509 Subject field","sidebarTitle":"Certificate-based authentication using multiple values from the X.509 SUBJECT field","href":"/docs/v25.1/certificate-based-authentication-using-the-x509-subject-field"}]},{"title":"Authenticate to CockroachDB Self-Hosted Clusters","sidebarTitle":"Authentication","href":"/docs/v25.1/authentication"},{"title":"Manage Encryption for CockroachDB Self-Hosted Clusters","sidebarTitle":"Encryption","href":"/docs/v25.1/encryption"},{"title":"Manage Cluster User Authorization","sidebarTitle":"Authorization","href":"/docs/v25.1/authorization"},{"title":"Table-based SQL Audit Logging","href":"/docs/v25.1/sql-audit-logging"},{"title":"Role-based SQL Audit Logging","href":"/docs/v25.1/role-based-audit-logging"},{"title":"Configure LDAP Authentication","sidebarTitle":"LDAP Authentication","href":"/docs/v25.1/ldap-authentication"},{"title":"Configure LDAP Authorization","sidebarTitle":"LDAP Authorization","href":"/docs/v25.1/ldap-authorization"},{"title":"GSSAPI Authentication (Enterprise)","sidebarTitle":"GSSAPI Authentication","href":"/docs/v25.1/gssapi_authentication"},{"title":"Cluster Single Sign-on (SSO) using JSON Web Tokens (JWTs)","sidebarTitle":"Cluster SSO using JWT","href":"/docs/v25.1/sso-sql"},{"title":"Single Sign-on (SSO) for DB Console","sidebarTitle":"DB Console SSO","href":"/docs/v25.1/sso-db-console"},{"title":"Rotate Security Certificates","href":"/docs/v25.1/rotate-certificates"},{"title":"Use HashiCorp Vault's Dynamic Secrets","sidebarTitle":"Use Hashicorp Vault's Dynamic Secrets","href":"/docs/v25.1/vault-db-secrets-tutorial"}]},{"group":"Monitoring and Alerting","pages":[{"title":"Monitoring and Alerting","sidebarTitle":"Overview","href":"/docs/v25.1/monitoring-and-alerting"},{"title":"Common Issues to Monitor","href":"/docs/v25.1/common-issues-to-monitor"},{"title":"Enable the Node Map","href":"/docs/v25.1/enable-node-map"},{"title":"Monitor CockroachDB with Prometheus","sidebarTitle":"Use Prometheus and Alertmanager","href":"/docs/v25.1/monitor-cockroachdb-with-prometheus"},{"title":"Essential Metrics for CockroachDB Self-Hosted Deployments","sidebarTitle":"Essential Metrics for CockroachDB self-hosted Deployments","href":"/docs/v25.1/essential-metrics-self-hosted"},{"title":"Essential Alerts for CockroachDB Self-Hosted Deployments","sidebarTitle":"Essential Alerts for CockroachDB self-hosted Deployments","href":"/docs/v25.1/essential-alerts-self-hosted"}]},{"group":"Administration","pages":[{"title":"DB Console Overview","href":"/docs/v25.1/ui-overview"},{"title":"Cluster Overview Page","href":"/docs/v25.1/ui-cluster-overview-page"},{"group":"Metrics Dashboards","pages":[{"title":"Overview Dashboard","sidebarTitle":"Overview","href":"/docs/v25.1/ui-overview-dashboard"},{"title":"Hardware Dashboard","sidebarTitle":"Hardware","href":"/docs/v25.1/ui-hardware-dashboard"},{"title":"Runtime Dashboard","sidebarTitle":"Runtime","href":"/docs/v25.1/ui-runtime-dashboard"},{"title":"Networking Dashboard","sidebarTitle":"Networking","href":"/docs/v25.1/ui-networking-dashboard"},{"title":"SQL Dashboard","sidebarTitle":"SQL","href":"/docs/v25.1/ui-sql-dashboard"},{"title":"Storage Dashboard","sidebarTitle":"Storage","href":"/docs/v25.1/ui-storage-dashboard"},{"title":"Replication Dashboard","sidebarTitle":"Replication","href":"/docs/v25.1/ui-replication-dashboard"},{"title":"Distributed Dashboard","sidebarTitle":"Distributed","href":"/docs/v25.1/ui-distributed-dashboard"},{"title":"Queues Dashboard","sidebarTitle":"Queues","href":"/docs/v25.1/ui-queues-dashboard"},{"title":"Slow Requests Dashboard","sidebarTitle":"Slow Requests","href":"/docs/v25.1/ui-slow-requests-dashboard"},{"title":"Changefeeds Dashboard","sidebarTitle":"Changefeeds","href":"/docs/v25.1/ui-cdc-dashboard"},{"title":"Overload Dashboard","sidebarTitle":"Overload","href":"/docs/v25.1/ui-overload-dashboard"},{"title":"TTL Dashboard","sidebarTitle":"TTL","href":"/docs/v25.1/ui-ttl-dashboard"},{"title":"Physical Cluster Replication Dashboard","sidebarTitle":"Physical Cluster Replication","href":"/docs/v25.1/ui-physical-cluster-replication-dashboard"},{"title":"Logical Data Replication Dashboard","sidebarTitle":"Logical Data Replication","href":"/docs/v25.1/ui-logical-data-replication-dashboard"},{"title":"Custom Chart Debug Page","href":"/docs/v25.1/ui-custom-chart-debug-page"}]},{"title":"Databases Page","href":"/docs/v25.1/ui-databases-page"},{"title":"Sessions Page","href":"/docs/v25.1/ui-sessions-page"},{"title":"Statements Page","href":"/docs/v25.1/ui-statements-page"},{"title":"Transactions Page","href":"/docs/v25.1/ui-transactions-page"},{"title":"Insights Page","href":"/docs/v25.1/ui-insights-page"},{"title":"Network Page","href":"/docs/v25.1/ui-network-latency-page"},{"title":"Jobs Page","href":"/docs/v25.1/ui-jobs-page"},{"title":"Schedules Page","href":"/docs/v25.1/ui-schedules-page"},{"title":"Advanced Debug Page","href":"/docs/v25.1/ui-debug-pages"},{"title":"Key Visualizer","href":"/docs/v25.1/ui-key-visualizer"},{"title":"WAL Failover","href":"/docs/v25.1/wal-failover"}]},{"group":"Backups and Restores","pages":[{"title":"Backup and Restore Overview","sidebarTitle":"Overview","href":"/docs/v25.1/backup-and-restore-overview"},{"title":"Take Full and Incremental Backups","sidebarTitle":"Full and Incremental Backups","href":"/docs/v25.1/take-full-and-incremental-backups"},{"title":"Take Backups with Revision History and Restore from a Point-in-time","sidebarTitle":"Backups with Revision History and Point-in-time Restore","href":"/docs/v25.1/take-backups-with-revision-history-and-restore-from-a-point-in-time"},{"title":"Take and Restore Encrypted Backups","sidebarTitle":"Encrypted Backup and Restore","href":"/docs/v25.1/take-and-restore-encrypted-backups"},{"title":"Take Locality-restricted Backups","sidebarTitle":"Locality-restricted Backup Execution","href":"/docs/v25.1/take-locality-restricted-backups"},{"title":"Take and Restore Locality-aware Backups","sidebarTitle":"Locality-aware Backup and Restore","href":"/docs/v25.1/take-and-restore-locality-aware-backups"},{"title":"Manage a Backup Schedule","sidebarTitle":"Scheduled Backups","href":"/docs/v25.1/manage-a-backup-schedule"},{"title":"Backup Validation","href":"/docs/v25.1/backup-validation"},{"title":"Expire Past Backups","href":"/docs/v25.1/expire-past-backups"},{"title":"Backup and Restore Monitoring","href":"/docs/v25.1/backup-and-restore-monitoring"}]},{"group":"File Storage","pages":[{"title":"Use Cloud Storage","sidebarTitle":"Cloud Storage","href":"/docs/v25.1/use-cloud-storage"},{"title":"Cloud Storage Authentication","href":"/docs/v25.1/cloud-storage-authentication"},{"title":"Use Userfile Storage","sidebarTitle":"Userfile Storage","href":"/docs/v25.1/use-userfile-storage"},{"title":"Use a Local File Server","sidebarTitle":"Local File Server","href":"/docs/v25.1/use-a-local-file-server"}]},{"group":"Cluster Maintenance","pages":[{"title":"Upgrade CockroachDB self-hosted","sidebarTitle":"Upgrade CockroachDB","href":"/docs/v25.1/upgrade-cockroach-version"},{"title":"Disaster Recovery Planning","href":"/docs/v25.1/disaster-recovery-planning"},{"title":"Restoring Backups Across Versions","href":"/docs/v25.1/restoring-backups-across-versions"},{"title":"Manage Long-Running Queries","href":"/docs/v25.1/manage-long-running-queries"},{"title":"Node Shutdown","href":"/docs/v25.1/node-shutdown"}]},{"group":"Logs","pages":[{"title":"Logging Overview","sidebarTitle":"Overview","href":"/docs/v25.1/logging-overview"},{"title":"Configure Logs","href":"/docs/v25.1/configure-logs"},{"title":"Logging Use Cases","href":"/docs/v25.1/logging-use-cases"},{"title":"Log SQL Activity to Datadog","href":"/docs/v25.1/log-sql-activity-to-datadog"},{"title":"Logging Best Practices","href":"/docs/v25.1/logging-best-practices"},{"title":"Critical Log Messages","href":"/docs/v25.1/critical-log-messages"}]},{"title":"Cluster API v2.0","sidebarTitle":"Cluster API","href":"/docs/v25.1/cluster-api"}]},{"group":"Schema Design","pages":[{"title":"Database Schemas","href":"/docs/v25.1/schema-design-overview"},{"title":"Computed Columns","href":"/docs/v25.1/computed-columns"},{"title":"Column Families","href":"/docs/v25.1/column-families"},{"title":"Scale to Multiple Regions","href":"/docs/v25.1/multiregion-scale-application"},{"group":"Indexes","pages":[{"title":"Secondary Indexes","href":"/docs/v25.1/schema-design-indexes"},{"title":"Index a Subset of Rows with Partial Indexes","sidebarTitle":"Partial Indexes","href":"/docs/v25.1/partial-indexes"},{"title":"Index Sequential Keys with Hash-sharded Indexes","sidebarTitle":"Hash-sharded Indexes","href":"/docs/v25.1/hash-sharded-indexes"},{"title":"Generalized Inverted Indexes","href":"/docs/v25.1/inverted-indexes"},{"title":"Full-Text Search","href":"/docs/v25.1/full-text-search"},{"title":"Trigram Indexes","href":"/docs/v25.1/trigram-indexes"},{"title":"Expression Indexes","href":"/docs/v25.1/expression-indexes"},{"title":"Spatial Indexes","href":"/docs/v25.1/spatial-indexes"}]},{"group":"Update a Database Schema","pages":[{"title":"Online Schema Changes","href":"/docs/v25.1/online-schema-changes"},{"title":"Migrate CockroachDB Schemas with Alembic","sidebarTitle":"Use Alembic","href":"/docs/v25.1/alembic"},{"title":"Migrate CockroachDB Schemas with Flyway","sidebarTitle":"Use Flyway","href":"/docs/v25.1/flyway"},{"title":"Migrate CockroachDB Schemas with Liquibase","sidebarTitle":"Use Liquibase","href":"/docs/v25.1/liquibase"}]}]},{"group":"Reads and Writes","pages":[{"title":"Reads and Writes in CockroachDB","sidebarTitle":"Overview","href":"/docs/v25.1/architecture/reads-and-writes-overview"},{"group":"Read Data","pages":[{"title":"Query Data","href":"/docs/v25.1/query-data"},{"title":"Reusable Views","href":"/docs/v25.1/views"},{"title":"Subqueries","href":"/docs/v25.1/subqueries"},{"title":"Temporary Tables","href":"/docs/v25.1/temporary-tables"},{"title":"Paginate Results","href":"/docs/v25.1/pagination"},{"title":"Follower Reads","href":"/docs/v25.1/follower-reads"},{"title":"AS OF SYSTEM TIME","sidebarTitle":"AS OF SYSTEM TIME","href":"/docs/v25.1/as-of-system-time"},{"title":"Query Spatial Data","href":"/docs/v25.1/query-spatial-data"}]},{"group":"Write Data","pages":[{"title":"Insert Data","href":"/docs/v25.1/insert-data"},{"title":"Update Data","href":"/docs/v25.1/update-data"},{"title":"Bulk-update Data","href":"/docs/v25.1/bulk-update-data"},{"title":"Delete Data","href":"/docs/v25.1/delete-data"},{"title":"Bulk-delete Data","href":"/docs/v25.1/bulk-delete-data"},{"title":"Batch Delete Expired Data with Row-Level TTL","href":"/docs/v25.1/row-level-ttl"}]},{"group":"Transactions","pages":[{"title":"Transactions","sidebarTitle":"Overview","href":"/docs/v25.1/transactions"},{"title":"Advanced Client-side Transaction Retries","href":"/docs/v25.1/advanced-client-side-transaction-retries"},{"title":"Life of a Distributed Transaction","href":"/docs/v25.1/architecture/life-of-a-distributed-transaction"},{"title":"Read Committed Transactions","href":"/docs/v25.1/read-committed"}]},{"title":"Test Your Application Locally","href":"/docs/v25.1/local-testing"},{"url":"https://www.cockroachlabs.com/docs/tutorials/sql-playground","title":"SQL Playground","href":"/links/tutorials/sql-playground"},{"group":"Database Management Tools","pages":[{"title":"Visualize CockroachDB Schemas with DBeaver","sidebarTitle":"DBeaver GUI","href":"/docs/v25.1/dbeaver"},{"title":"Use IntelliJ IDEA with CockroachDB","sidebarTitle":"IntelliJ IDEA","href":"/docs/v25.1/intellij-idea"}]},{"title":"JSON Support","href":"/docs/v25.1/demo-json-support"}]},{"group":"Stream Data","pages":[{"title":"Change Data Capture Overview","href":"/docs/v25.1/change-data-capture-overview"},{"group":"Get Started with Changefeeds","pages":[{"title":"Create and Configure Changefeeds","href":"/docs/v25.1/create-and-configure-changefeeds"},{"title":"Changefeed Best Practices","href":"/docs/v25.1/changefeed-best-practices"},{"group":"Changefeed Messages","pages":[{"title":"Changefeed Messages","sidebarTitle":"Overview","href":"/docs/v25.1/changefeed-messages"}]},{"title":"Changefeed Sinks","href":"/docs/v25.1/changefeed-sinks"},{"title":"Changefeed Examples","href":"/docs/v25.1/changefeed-examples"}]},{"group":"Monitor Changefeeds","pages":[{"title":"Monitor and Debug Changefeeds","sidebarTitle":"Overview","href":"/docs/v25.1/monitor-and-debug-changefeeds"},{"title":"Changefeed Monitoring Guide","sidebarTitle":"Monitoring Guide","href":"/docs/v25.1/changefeed-monitoring-guide"},{"title":"Protect Changefeed Data from Garbage Collection","sidebarTitle":"Protect Changefeed Data","href":"/docs/v25.1/protect-changefeed-data"}]},{"group":"Optimize Changefeeds","pages":[{"title":"Change Data Capture Queries","href":"/docs/v25.1/cdc-queries"},{"title":"Changefeeds on Tables with Column Families","href":"/docs/v25.1/changefeeds-on-tables-with-column-families"},{"title":"Export Data with Changefeeds","href":"/docs/v25.1/export-data-with-changefeeds"},{"title":"Changefeeds in Multi-Region Deployments","href":"/docs/v25.1/changefeeds-in-multi-region-deployments"}]},{"group":"Changefeed Tutorials","pages":[{"group":"Stream a Changefeed to an Amazon MSK Cluster","pages":[{"title":"Stream a Changefeed to Amazon MSK","sidebarTitle":"Amazon MSK","href":"/docs/v25.1/stream-a-changefeed-to-amazon-msk"},{"title":"Stream a Changefeed to Amazon MSK Serverless","sidebarTitle":"Amazon MSK Serverless","href":"/docs/v25.1/stream-a-changefeed-to-amazon-msk-serverless"}]},{"title":"Connect to a Changefeed Kafka Sink with OAuth Using Okta","href":"/docs/v25.1/connect-to-a-changefeed-kafka-sink-with-oauth-using-okta"},{"title":"Stream a Changefeed to a Confluent Cloud Kafka Cluster","href":"/docs/v25.1/stream-a-changefeed-to-a-confluent-cloud-kafka-cluster"}]},{"group":"Technical Overview","pages":[{"title":"How Does a Changefeed Work?","href":"/docs/v25.1/how-does-a-changefeed-work"}]},{"title":"Advanced Changefeed Configuration","href":"/docs/v25.1/advanced-changefeed-configuration"}]},{"group":"Cross-Cluster Replication","pages":[{"group":"Logical Data Replication","pages":[{"title":"Logical Data Replication","sidebarTitle":"Overview","href":"/docs/v25.1/logical-data-replication-overview"},{"title":"Set Up Logical Data Replication","href":"/docs/v25.1/set-up-logical-data-replication"},{"title":"Manage Logical Data Replication","href":"/docs/v25.1/manage-logical-data-replication"},{"title":"Logical Data Replication Monitoring","sidebarTitle":"Monitor Logical Data Replication","href":"/docs/v25.1/logical-data-replication-monitoring"}]},{"group":"Physical Cluster Replication","pages":[{"title":"Physical Cluster Replication","sidebarTitle":"Overview","href":"/docs/v25.1/physical-cluster-replication-overview"},{"title":"Set Up Physical Cluster Replication","href":"/docs/v25.1/set-up-physical-cluster-replication"},{"title":"Fail Over from a Primary Cluster to a Standby Cluster","sidebarTitle":"Fail Over from a Primary to a Standby Cluster","href":"/docs/v25.1/failover-replication"},{"title":"Physical Cluster Replication Monitoring","sidebarTitle":"Monitor a Replication Stream","href":"/docs/v25.1/physical-cluster-replication-monitoring"},{"title":"Physical Cluster Replication Technical Overview","sidebarTitle":"Technical Overview","href":"/docs/v25.1/physical-cluster-replication-technical-overview"},{"group":"Cluster Virtualization","pages":[{"title":"Cluster Virtualization Overview","sidebarTitle":"Overview","href":"/docs/v25.1/cluster-virtualization-overview"},{"title":"Work with virtual clusters","sidebarTitle":"Work with Virtual Clusters","href":"/docs/v25.1/work-with-virtual-clusters"},{"title":"Cluster Setting Scopes with Cluster Virtualization enabled","sidebarTitle":"Setting Scopes","href":"/docs/v25.1/cluster-virtualization-setting-scopes"},{"title":"Cluster Metric Scopes with Cluster Virtualization enabled","sidebarTitle":"Metric Scopes","href":"/docs/v25.1/cluster-virtualization-metric-scopes"}]}]}]},{"group":"Multi-Region Capabilities","pages":[{"title":"Multi-Region Capabilities Overview","sidebarTitle":"Overview","href":"/docs/v25.1/multiregion-overview"},{"title":"Multi-Region Survival Goals","sidebarTitle":"Survival Goals","href":"/docs/v25.1/multiregion-survival-goals"},{"group":"Data Domiciling and Performance","pages":[{"title":"Table Localities","href":"/docs/v25.1/table-localities"},{"title":"Table Partitioning","href":"/docs/v25.1/partitioning"},{"title":"Data Domiciling with CockroachDB","sidebarTitle":"Data Domiciling with CockroachDB Tutorial","href":"/docs/v25.1/data-domiciling"}]},{"title":"How to Choose a Multi-Region Configuration","href":"/docs/v25.1/choosing-a-multi-region-configuration"},{"title":"Multi-Region Zone Config Extensions","href":"/docs/v25.1/zone-config-extensions"},{"group":"Multi-Region Tutorials","pages":[{"title":"Low Latency Reads and Writes in a Multi-Region Cluster","sidebarTitle":"Low Latency Reads and Writes","href":"/docs/v25.1/demo-low-latency-multi-region-deployment"},{"title":"Migrate to Multi-Region SQL","sidebarTitle":"Migrate to Multi-Region SQL with Replication Zones","href":"/docs/v25.1/migrate-to-multiregion-sql"}]}]},{"group":"Optimize Performance","pages":[{"title":"Optimize Statement Performance Overview","sidebarTitle":"Overview","href":"/docs/v25.1/make-queries-fast"},{"title":"SQL Performance Best Practices","href":"/docs/v25.1/performance-best-practices-overview"},{"title":"Indexes","href":"/docs/v25.1/indexes"},{"title":"Map SQL Activity using an Application Name","href":"/docs/v25.1/map-sql-activity-to-app"},{"title":"Cost-Based Optimizer","href":"/docs/v25.1/cost-based-optimizer"},{"title":"Vectorized Query Execution","sidebarTitle":"Vectorized Execution Engine","href":"/docs/v25.1/vectorized-execution"},{"title":"Load-Based Splitting","href":"/docs/v25.1/load-based-splitting"},{"title":"Replication Controls","href":"/docs/v25.1/configure-replication-zones"},{"title":"Admission Control","href":"/docs/v25.1/admission-control"},{"title":"Monitor and Analyze Transaction Contention","href":"/docs/v25.1/monitor-and-analyze-transaction-contention"},{"title":"Performance Tuning Recipes","href":"/docs/v25.1/performance-recipes"},{"group":"Performance Tuning Tutorials","pages":[{"title":"Statement Tuning with EXPLAIN","sidebarTitle":"Statement Tuning with EXPLAIN","href":"/docs/v25.1/sql-tuning-with-explain"},{"title":"Apply SQL Statement Performance Rules","href":"/docs/v25.1/apply-statement-performance-rules"},{"title":"Troubleshoot Lock Contention","href":"/docs/v25.1/troubleshoot-lock-contention"}]}]},{"group":"Integrate","pages":[{"title":"Integrate CockroachDB with Satori","sidebarTitle":"Integrate with Satori","href":"/docs/v25.1/satori-integration"}]}]},{"tab":"Migrate","icon":"arrow-right-arrow-left","pages":[{"title":"Migrate","href":"/docs/molt/migration-overview"}]},{"tab":"SQL","icon":"code","pages":[{"title":"SQL","href":"/docs/v25.1/sql-statements"}]},{"tab":"Reference","icon":"book","pages":[{"title":"Reference","href":"/docs/v25.1/architecture/glossary"}]},{"tab":"Cluster API","icon":"rocket","pages":[{"title":"Cluster API","href":"/docs/api/cluster"}]},{"tab":"Troubleshoot","icon":"bug","pages":[{"title":"Troubleshoot","href":"/docs/v25.1/troubleshooting-overview"}]}]},{"version":"v24.3","tag":"LTS","pages":[{"title":"v24.3","href":"/docs/v24.3/connect-to-the-database"}]},{"version":"v24.1","tag":"LTS","pages":[{"title":"v24.1","href":"/docs/v24.1/connect-to-the-database"}]},{"version":"v23.2","tag":"LTS","pages":[{"title":"v23.2","href":"/docs/v23.2/connect-to-the-database"}]},{"version":"v23.1","tag":"Unsupported","pages":[{"title":"v23.1","href":"/docs/v23.1/connect-to-the-database"}]}]},{"product":"Cloud Deployments","icon":"cloud","description":"Fully managed CockroachDB","pages":[{"title":"Cloud Deployments","href":"/docs/cockroachcloud"}]},{"product":"Releases","icon":"list","description":"Version history, support policy \u0026 advisories","pages":[{"title":"Releases","href":"/docs/releases"}]}]},"basePath":"","title":"Connect to a CockroachDB Cluster - CockroachDB","buildId":"dpl_DqYu5MPb49gWBBbUGgpHQUmCHY3P","deploymentId":"dpl_DqYu5MPb49gWBBbUGgpHQUmCHY3P","dynamics":[],"chunks":[]}