{"record":{"id":"fe86499496489eba","repo":"infiniflow/ragflow","slug":"database-connection-failed-n-e","errorCode":null,"errorMessage":"Database Connection Failed! \\n{e}","messagePattern":"Database Connection Failed! \\\\n(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"agent/tools/exesql.py","lineNumber":178,"sourceCode":"                else:\n                    c, s = db, \"default\"\n                return c, s\n\n            catalog, schema = _parse_catalog_schema(self._param.database)\n            if not catalog:\n                raise Exception(\"For Trino, `database` must be 'catalog.schema' or at least 'catalog'.\")\n\n            http_scheme = \"https\" if os.environ.get(\"TRINO_USE_TLS\", \"0\") == \"1\" else \"http\"\n            auth = None\n            if http_scheme == \"https\" and self._param.password:\n                auth = BasicAuthentication(self._param.username, self._param.password)\n\n            try:\n                db = trino.dbapi.connect(\n                    host=safe_host, port=int(self._param.port or 8080), user=self._param.username or \"ragflow\", catalog=catalog, schema=schema or \"default\", http_scheme=http_scheme, auth=auth\n                )\n            except Exception as e:\n                raise Exception(\"Database Connection Failed! \\n\" + str(e))\n        elif self._param.db_type == \"IBM DB2\":\n            import ibm_db\n\n            conn_str = f\"DATABASE={self._param.database};HOSTNAME={safe_host};PORT={self._param.port};PROTOCOL=TCPIP;UID={self._param.username};PWD={self._param.password};\"\n            try:\n                conn = ibm_db.connect(conn_str, \"\", \"\")\n            except Exception as e:\n                raise Exception(\"Database Connection Failed! \\n\" + str(e))\n\n            try:\n                sql_res = []\n                formalized_content = []\n                for single_sql in sqls:\n                    if self.check_if_canceled(\"ExeSQL processing\"):\n                        return\n\n                    single_sql = single_sql.replace(\"```\", \"\").strip()\n                    if not single_sql:","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/exesql.py#L160-L196","documentation":"Error \"Database Connection Failed! \\n{e}\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at agent/tools/exesql.py:178 when the library encounters an invalid state.","commonSituations":"The database server is unreachable, credentials are wrong, or the target database does not exist; validating the connection settings prevents this error.","solutions":["Verify host, port, credentials, and database name for the connection.","Check network reachability and that the database server is running, then retry."],"exampleFix":"# test connectivity first\nimport pymysql\nconn = pymysql.connect(host=host, port=port, user=user, password=pwd, database=db)","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}