def execute_query()

in src/lindorm_mcp_server/lindorm_wide_table.py [0:0]


    def execute_query(self, query: str) -> str:
        """Execute SQL commands."""
        try:
            if not query.strip().upper().startswith("SELECT"):
                return (f"Query should start with SELECT. " +
                        "Example: SELECT * FROM table ")

            self.cursor.execute(query)
            # Regular SELECT queries
            columns = [desc[0] for desc in self.cursor.description]
            rows = self.cursor.fetchall()
            result = [",".join(map(str, row)) for row in rows]
            return "\n".join([",".join(columns)] + result)
        except Error as e:
            error_msg = str(e)
            if "Detect inefficient query" in error_msg:
                return ("Your query was identified as inefficient. " +
                        "Please add /*+ _l_allow_filtering_ */ hint after the SELECT keyword.\n" +
                        "Example: SELECT /*+ _l_allow_filtering_ */ * FROM table\n" +
                        "Instead of: SELECT * FROM table")
            elif "JOIN is not allowed" in error_msg or "UNION is not allowed" in error_msg:
                return "JOIN UNION is not allowed. Please execute 'ALTER SYSTEM SET `lindorm.sql.join_union.disabled`=FALSE' to enable join."
            return f"Error executing query: {str(e)}"