commit_transaction
Finalize database changes by committing the current transaction to ensure data persistence in CockroachDB.
Instructions
Commit the current transaction.
Returns:
Commit status.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/cockroachdb_mcp/server.py:391-401 (handler)MCP tool handler for commit_transaction, registered with @mcp.tool(), delegates to connection_manager.commit_transaction()@mcp.tool() async def commit_transaction() -> dict[str, Any]: """Commit the current transaction. Returns: Commit status. """ try: return await connection_manager.commit_transaction() except Exception as e: return {"status": "error", "error": str(e)}
- Core implementation of commit_transaction in ConnectionManager class: commits the DB transaction if active, updates connection state.async def commit_transaction(self) -> dict[str, Any]: """Commit the current transaction. Returns: Commit status. """ conn = await self.ensure_connected() if not self._state.in_transaction: return {"status": "error", "error": "No transaction in progress"} try: await conn.commit() await conn.set_autocommit(True) self._state.in_transaction = False return {"status": "committed", "message": "Transaction committed"} except Exception as e: return {"status": "error", "error": str(e)}