{"record":{"id":"3524ec9ce6c4d5bd","repo":"apache/beam","slug":"unsupported-database-adapter-self-db-adapter","errorCode":null,"errorMessage":"Unsupported database adapter: {self.db_adapter}","messagePattern":"Unsupported database adapter: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py","lineNumber":217,"sourceCode":"    \"\"\"Returns a function that creates a new database connection.\n\n      The returned connector function creates database connections that should\n      be properly closed by the caller when no longer needed.\n      \"\"\"\n    if self.db_adapter == DatabaseTypeAdapter.POSTGRESQL:\n      return lambda: pg8000.connect(\n          host=self.host, port=self.port, database=self.db_id, user=self.user,\n          password=self.password, **self.connect_kwargs)\n    elif self.db_adapter == DatabaseTypeAdapter.MYSQL:\n      return lambda: pymysql.connect(\n          host=self.host, port=self.port, database=self.db_id, user=self.user,\n          password=self.password, **self.connect_kwargs)\n    elif self.db_adapter == DatabaseTypeAdapter.SQLSERVER:\n      return lambda: pytds.connect(\n          dsn=self.host, port=self.port, database=self.db_id, user=self.user,\n          password=self.password, **self.connect_kwargs)\n    else:\n      raise ValueError(f\"Unsupported database adapter: {self.db_adapter}\")\n\n  def get_db_url(self) -> str:\n    return self.db_adapter.to_sqlalchemy_dialect() + \"://\"\n\n\nQueryConfig = Union[CustomQueryConfig,\n                    TableFieldsQueryConfig,\n                    TableFunctionQueryConfig]\n\n\nclass CloudSQLEnrichmentHandler(EnrichmentSourceHandler[beam.Row, beam.Row]):\n  \"\"\"Enrichment handler for Cloud SQL databases.\n\n  This handler is designed to work with the\n  :class:`apache_beam.transforms.enrichment.Enrichment` transform.\n\n  To use this handler, you need to provide one of the following query configs:\n    * CustomQueryConfig - For providing a custom query function","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py#L199-L235","documentation":"get_connector_handler builds a lambda that opens DBAPI connections using the driver matching db_adapter (pg8000 for PostgreSQL, pymysql for MySQL, pytds for SQL Server). If db_adapter is none of the supported DatabaseTypeAdapter values, the handler raises ValueError rather than guessing a driver.","triggerScenarios":"Passing db_adapter as a raw string like 'postgres' instead of a DatabaseTypeAdapter enum member, or an adapter type not covered by the if/elif chain (e.g. Oracle).","commonSituations":"Passing a plain string instead of the enum; using a database flavor the handler does not support; refactors that renamed enum members.","solutions":["Use DatabaseTypeAdapter.POSTGRESQL, MYSQL, or SQLSERVER instead of a raw string.","Check the DatabaseTypeAdapter enum for the full set of supported adapters.","For an unsupported database, use a different enrichment handler or extend get_connector_handler."],"exampleFix":"# before\nconfig = QueryCloudSQLConnectionConfig(db_adapter=\"postgres\", host=uri, ...)\n# after\nfrom apache_beam.transforms.enrichment_handlers.cloudsql import DatabaseTypeAdapter\nconfig = QueryCloudSQLConnectionConfig(db_adapter=DatabaseTypeAdapter.POSTGRESQL, host=uri, ...)","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["python","configuration","cloudsql","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}